Automation

 View Only
  • 1.  Determine vCenter name from VM or ESX Host

    Posted Apr 23, 2013 04:29 AM

    Hi All,

    Am trying to determine a way to fetch vCenter name for the VM / ESX host is registered to. Is there a vSphere CLI script I can use ?

    This is needed because we receive an alert from monitoring agents saying so and so VM or so and so ESX server is down. Rather than hopping between multiple vCenters we should a have more simpler way to find vCenter name through some mechanism. Please advise.

    thanks a ton in advance.

    Shaheer



  • 2.  RE: Determine vCenter name from VM or ESX Host

    Broadcom Employee
    Posted Apr 23, 2013 01:20 PM

    Welcome!

    Discussion moved from VMware vCenter™ to VMware vSphere™ PowerCLI



  • 3.  RE: Determine vCenter name from VM or ESX Host

    Posted Apr 23, 2013 01:26 PM

    welcome shaheer!!

    this is what we've done in our environment to address the similer concern.

    http://pingforinfo.com/powercli-sccript-for-exporting-vm-details-to-html/

    we've autamated it with the help of windows task scheduler. Now we have the VM inverntory dailiy. So whenecer a VM failurre alert comes its just the mater of searching the inventory (HTML) file with the VM name. 



  • 4.  RE: Determine vCenter name from VM or ESX Host

    Posted Apr 23, 2013 01:31 PM

    The vCenter Server name is in the Uid property. You can use the string Split() method to extract the vCenter Server name:

    Get-VM | Select-Object Name,@{N="vCenter";E={$_.Uid.Split('@')[1].Split(':')[0]}}
    Get-VMHost | Select-Object Name,@{N="vCenter";E={$_.Uid.Split('@')[1].Split(':')[0]}}