VMware Cloud Community
cdomansky
Contributor
Contributor
Jump to solution

Log into multiple vCenter Servers using PowerCLI

So, I am having some troubles setting up a connection to multiple servers at the same time.

Here is the current configuration pulled using Get-PowerCLIConfiguration

Capture.PNG

I have tried to connect using:

  • Connect-VIServer Server1, Server2

  • $hosts =@(

     "Server1",

     "Server2

);

$user="me"

$password="mypassword"

Connect-VIServer -Server $hosts -User $user -Password $password

After displaying the contents of the $defaultviservers array, it changes to the last server that it had connected to and never more than just the one.

Some thoughts on this would be appreciated.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try setting the DefaultVIServerMode to Multiple for the Session and User scope as well.

The priority is Session-User-AllUsers (high to low)

Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope ([VMware.VimAutomation.ViCore.Types.V1.ConfigurationScope]::User)

Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope ([VMware.VimAutomation.ViCore.Types.V1.ConfigurationScope]::Session)


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

View solution in original post

0 Kudos
3 Replies
LucianoPatrão
Jump to solution

Hi,

A very easy way.

http://professionalvmware.com/2011/03/some-powercli-101-connecting-to-multiple-vcenters/

To choose which one to connect, use -menu

Luciano Patrão

VCP-DCV, VCAP-DCV Design 2023, VCP-Cloud 2023
vExpert vSAN, NSX, Cloud Provider, Veeam Vanguard
Solutions Architect - Tech Lead for VMware / Virtual Backups

________________________________
If helpful Please award points
Thank You
Blog: https://www.provirtualzone.com | Twitter: @Luciano_PT
0 Kudos
cdomansky
Contributor
Contributor
Jump to solution

The problem I have with this is that I am going to be setting up an automated task which will run a PowerCLI script.  I will not have the option of user entry at all.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try setting the DefaultVIServerMode to Multiple for the Session and User scope as well.

The priority is Session-User-AllUsers (high to low)

Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope ([VMware.VimAutomation.ViCore.Types.V1.ConfigurationScope]::User)

Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope ([VMware.VimAutomation.ViCore.Types.V1.ConfigurationScope]::Session)


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

0 Kudos