Automation

 View Only
  • 1.  PowerCli - Find VM in Multiple vCenter

    Posted Nov 01, 2018 11:05 AM

    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

    }



  • 2.  RE: PowerCli - Find VM in Multiple vCenter

    Posted Nov 01, 2018 11:09 AM

    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



  • 3.  RE: PowerCli - Find VM in Multiple vCenter

    Posted Nov 01, 2018 11:38 AM

    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

    }



  • 4.  RE: PowerCli - Find VM in Multiple vCenter
    Best Answer

    Posted Nov 01, 2018 11:41 AM

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