Is anyone using PowerCLI in API endpoints? I have another user that is running into a problem where if they call the APIs at the same time, PowerCLI complains that it is no longer connected. I assume it’s because it maintains the connections at a process level and not a runspace level.
So the API psuedocode is something like:
Connect
Perform PowerCLI Operations
Disconnect
But what happens is that if 2 APIs are running at the same time one will connect, finish it’s operation and disconnect and then the second API will fail to perform operations because everything disconnected.
Both connect connect to the same server, but when one of them disconnect, both disconnects and the “slowest” running one will fail because it’s now disconnected?
If it’s not the same server. Then Disconnect-VIServer has a -server parameter that I’d guess only disconnects that one server. One might need to configure power lines for multiple sessions though (Set-PowerCLIConfiguration -DefaultVIServerMode Multiple)
And, since my middle name is “workaround”, if it where a limitation of PowerCLI connecting simultaneously to the same server, one may be able to work around it by setting up some cname records for the same server one per endpoint maybe?
I have a colleague testing PSU with PowerCLI, I’ll check if I can learn something from it tomorrow.
Hello, I am the one working on this so we have 13 vcenters and these API’s are running powercli command on 400+ vm across all datacenters. so the powershell connects to all the vcenter (13) searches for the VM finds and different API’s do different tasks. So if one API finishes first then it closes the vcenter connection and kills all the other running API’s as it just disconnected all the vcenters. because of the type of jobs and environment need to connect to all the vcenters at the sametime.
Aside from running PS jobs with Start-Job and Wait-Job, you could do similar with Invoke-UAJob -Wait. The bulk of the script would run in a PSU job that would run in its own process.