Multiple Default Servers in PowerCLI

I support multiple vCenter environments. The most recent versions of PowerCLI support this through the use of multiple default servers. When you are connected to multiple vCenters commands such as ‘Get-VM’ will return VMs from both default servers.

When you first attempt to connect to a second vCenter server you will receive the following warning.

Working with multiple default servers?

    Select [Y] if you want to work with more than one default servers. In this case, every time when you connect to a different server using Connect-VIServer,  the new server connection is stored in an array variable together with the previously connected servers. When you run a cmdlet and the target servers
cannot be determined from the specified parameters, the cmdlet runs against all servers stored in the array variable.
    Select [N] if you want to work with a single default server. In this case, when you run a cmdlet and the target servers cannot be determined from the specified parameters, the cmdlet runs against the last connected server.
    You can change your preference at any time using  the DefaultServerMode parameter of Set-PowerCLIConfiguration.
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

This can be bothersome if you really want to access multiple default servers. The following command:

Set-PowerCLIConfiguration -DefaultVIServerMode multiple -Confirm:$false

Will set your default server mode to allow multiples.

Proxy Policy    Default Server
                Mode
------------    ---------------
UseSystemProxy  Multiple

Now when you try to connect to a second vCenter you will just connect, no input needed.

This entry was posted in Virtualization. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.