VMware Cloud Community
Bunty11
Hot Shot
Hot Shot
Jump to solution

PowerCli - Find VM in Multiple vCenter

How to find a VM in multiple vCenter using powercli.

I tried :

$vCenters = @("xx""xx")

ForEach-Object ($vCenter -in $vCenters)

{

$Connect = Connect-VIServer $vCenter -User xxxxx -Password xxxxx

}

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

No, if you set the mode to Multiple, it will automatically search in all connected vCenters.


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Did you check that the DefaultVIServerMode is set to Multiple?

And with $global:defaultviservers you can check to which vCenters you are connected.

$vCenters = 'vc1','vc2'

Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false

Connect-VIServer -Server $vCenters -User xxxxx -Password xxxxx

$global:DefaultVIServers


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

Reply
0 Kudos
Bunty11
Hot Shot
Hot Shot
Jump to solution

thanks lucd

and for searching vms in multiple vcenter do i need to do as below ???

ForEach-Object ($vCenter -in $vCenters)

{

Get-VM -Name $VmName -Server $vCenters

}

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

No, if you set the mode to Multiple, it will automatically search in all connected vCenters.


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

Reply
0 Kudos