Yes, you will have to switch to "multiple" mode first.
You can do this with the Set-PowerCLIConfiguration cmdlet and the DefaultVIServerMode switch.
Then you connect to all the vSphere servers you need to use. You can check by displaying the following variable
Your script will now run against all the connected servers,
An alternative is to connect all your vCenters in linked mode.
just to complete Luc post: when connecting to LinkedMode vCenters, use the '-AllLinked' parameter on Connect-VIServer
Ok thanks for the info. I'm still having an issue though:
set-powercliconfiguration -defaultviservermode multiple
I connected to one vcenter
Then I connected to another vcenter
But when I display the
variable it still only shows one of the vcenters
Any ideas why is it not showing both vCenters?
First, a clarification, connecting, with AllLinked set to $true, to a vCenter that is part of a vCenter Server federation, is not the same as running PowerCLI in Multiple mode.
In Multiple mode all vSphere Server connections that are made, are stored together in the $global:defaultVIServers variable.
All cmdlets, that do no specify a specific vSphere Server with the Server parameter, will be executed to all vSphere servers in the $global:defaultVIServers variable.
For your issue, let's first check if all is configured correctly.
Check if the configuration is saying "Multiple" for all the scopes.
If you see something like this
the setting will only be for your current session.
When you stop/start the session, the setting will be gone.
You can change the setting for AllUsers, like this
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope AllUsers
Then you will see this
and the configuration will be remembered between sessions.
It was set to multiple for "all users" but not for "user". I ran
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope User
and that resolved it - thanks!
I was also facing the same problem and use the method provided by you. But when I have tested it it was not working then I have open new session of power CLI then its stared working.
Note:- Please open a new session after changing your configuration so you get desired output.
Note that you can also change that setting in the "session" scope, that way you shouldn't have to restart your session.
So finally how you did this simultaneously to connect all the VC.
I also trying to do the same but no luck.
I want to get Multiple VM's information from multiple VCs, but currently I am pushing this using Foreach loop to get inside VC's details.
I want to run my script parallelly on all mentioned VCs.
LucD assist me to use Job but didn't understand so looking for some example to get this done.
Your help appreciated.