Hello,
I occasionally get this error:
You have modified the global:DefaultVIServer and global:DefaultVIServers system variables. This is not allowed. Please reset them to $null and reconnect to the vSphere server.
I have tried to fix the issue with this piece of code:
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false | Out-Null
$settings=@{
Scope="AllUsers"
DefaultVIServerMode="Multiple"
ProxyPolicy="NoProxy"
ParticipateInCeip=$false
DisplayDeprecationWarnings=$false
WebOperationTimeoutSeconds="-1"
}
Set-PowerCLIConfiguration @Settings -Confirm:$false
I still get the error from time to time. How can I avoid this error?
Are you doing anything with Runspaces?
From which environment do you run your PowerCLI scripts?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello @LucD
I expose some functionality through a webservice, asp.net mvc.
Each user can then call some functions in a powershell script which resides on the webservice server.
A new powershell instance is created for each powershell function call. Multiple instances may be executing simultaneously.
And that is probably the cause of the errors, PowerCLI is not threadsafe.
You might want to look at the Get-PowerCLIContext and Use-PowerCLIContext cmdlets that were introduced in PowerCLI 12.2
See also New Release – VMware PowerCLI 12.2
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks a lot i will look into that!