VMware Cloud Community
DroppedAtBirth
Contributor
Contributor
Jump to solution

1.5 Upgrade Issues

Currently have a service that runs powershell scripts thru .net thru System.Management.Automation. Using pipline.invoke. Have many script that all work on 1.0. installled 1.5 and keep getting "Cannot invoke this function because the current host does not implement it". Tried many things to get it to work but finally uninstalled 1.5 and re-installed 1.0 and all work again.

Any Ideas??

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Or as a one-liner

(Get-View SessionManager).Logout()


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
9 Replies
marco_shaw
Enthusiast
Enthusiast
Jump to solution

Can you provide an example of what you're trying to run in the pipeline? I've not checked whether the toolkit provides a public API or the only option is to add the snapin and call its cmdlets.

0 Kudos
DroppedAtBirth
Contributor
Contributor
Jump to solution

As I said this all works fine with 1.0 installed. with 1.5 it doesn't

First it loads a new runspace with the vim.psc1 as a config

Then runs

pipeline.invoke(" $connect = Connect-VIServer -Server ....... username and password in string

Get-DataCenter

Disconnect-VIServer -Confirm:$false

")

Obviously there are more complicated scripts that run, but this is the first script that runs, but the majority of the script get data back to sync up with our internal systems. Nothing very complicated. But when 1.5 is installed I get "Cannot invoke this function because the current host does not implement it" when pipeline.invoke is called.

0 Kudos
marco_shaw
Enthusiast
Enthusiast
Jump to solution

I just wanted to make sure you were't linking the specific assemblies.

Maybe someone else will speak up and help out, but I've never used Invoke() like that (by passing an argument)... I'm not saying it isn't supported though, but cool if it is supposed to work.

0 Kudos
marco_shaw
Enthusiast
Enthusiast
Jump to solution

Invoke docs:

I don't program enough to know what a "Ienumerable" actually is...

So the options to invoke Invoke() are: simply as Invoke() or Invoke(IEnumerable).

0 Kudos
DroppedAtBirth
Contributor
Contributor
Jump to solution

sorry, I miss spoke(typed), haven't changed any of the powershell .net code for while. Here is the actually code.

scriptext = "Connect-VIServer..........."

pipeline.Commands.AddScript(scriptText)

results = pipeline.Invoke()

0 Kudos
DroppedAtBirth
Contributor
Contributor
Jump to solution

Found the problem.

Disconnect-VIServer -Confirm:$false is what is causing the errors, removing it fromt he bottom of the script works. Of course this leaves tons of open sessions so until whatever is wrong with Disconnect-VIServer is fixed we are stuck on 1.0

0 Kudos
admin
Immortal
Immortal
Jump to solution

Yes, we have (or maybe it was had) a similar problem with PowerGUI it seems.

You're not stuck though, you can run

$serviceInstance = get-view serviceinstance
$sessionManager = get-view $serviceInstance.Content.SessionManager
$sessionManager.Logout()

LucD
Leadership
Leadership
Jump to solution

Or as a one-liner

(Get-View SessionManager).Logout()


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
DroppedAtBirth
Contributor
Contributor
Jump to solution

Thanks c_shanklin and LucD, that works great.

0 Kudos