VMware Cloud Community
mark_chuman
Hot Shot
Hot Shot
Jump to solution

Working with multiple vCenter servers in PowerCLI

Set VI server mode to multiple:

Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false

Connect to two vCenter servers:

Connect-VIServer -server vc1, vc2 -user userid

Find cluster and not specify VC:

Get-Datacenter -Cluster clusterA

Datacenter for cluster is correctly displayed:

name of datacenter in VC1

name of datacenter in VC2

Try to specify which VC to query:

Get-Datacenter -Cluster cluster -server VC2

names of three datacenters are returned that does not make sense (only one contains the cluster)

Trying to figure out how to best work with simultaneous VC connections in a script and dictate which VC I want to run a command against as opposed to disconnecting and reconnecting etc.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I think there might be an issue with the cmdlet.

You are using PowerCLI 5.5 R2 I assume ?

When you try like this

Get-Datacenter -Cluster (Get-Cluster -Name ClusterA -Server VC1)

does it return 1 datacenter or 2 ?


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

View solution in original post

0 Kudos
7 Replies
LucD
Leadership
Leadership
Jump to solution

Did it actually say "-Cluster cluster" (without the 'a') ?

And what do the Get-Cluster cmdlets themselves return ?

Get-Cluster -Name clustera

Get-Cluster -Name cluster -Server VC2


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

mark_chuman
Hot Shot
Hot Shot
Jump to solution

Sorry, typo on my part (was "sanitizing" the data) - it is clusterA in both commands.

Get-Cluster comes back with all clusters from the two vCenter servers I'm connected to.

Thanks!!!!

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Even when you do ?

Get-Cluster -Name cluster -Server VC2


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

mark_chuman
Hot Shot
Hot Shot
Jump to solution

So, when I have a cluster named ClusterA in both VCs and I do a get-cluster -name ClusterA, I get two results for ClusterA.  If I specify either VC with -server VC1 or VC2 I get only one result.  Now, when I add in get-datacenter -cluster ClusterA -server VCA or VCB it returns all datacenters in the VC.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I think there might be an issue with the cmdlet.

You are using PowerCLI 5.5 R2 I assume ?

When you try like this

Get-Datacenter -Cluster (Get-Cluster -Name ClusterA -Server VC1)

does it return 1 datacenter or 2 ?


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

0 Kudos
mark_chuman
Hot Shot
Hot Shot
Jump to solution

Yes, I'm on 5.5, U2.  That worked and returns only one datacenter.  Not exactly sure why that worked as I view it as boiling down to get-datacenter -cluster clustername, but thank you for this work-around.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Like I said, I think there might be an "issue" with the cmdlet.

Perhaps someone from the PowerCLI Dev Team could give an explanation ?


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

0 Kudos