1 Reply Latest reply on Nov 3, 2017 10:07 PM by nicholas1982

    List VMs with Hostname Viewable

    TheVMinator Master

      I'd like to get a list of all VMs in my environment.  Then for each one, I'd like to know if Vmware tools is installled and working, then I'd like to know if  the hostname inside the GuestOS is viewable, and if so what it is. 

      How can I do this with PowerCLI?

        • 1. Re: List VMs with Hostname Viewable
          nicholas1982 Hot Shot

          Does this work for you?


          $VMs = Get-VM


          $Report = @()

          foreach ($VM in $VMs){


          $Tools = $VM.ExtensionData.Guest.ToolsStatus

          $dns = $VM.ExtensionData.Guest.Hostname


          $Report += New-Object PSObject -Property @{


          VM_Name = $VM

          Tools_Status = $Tools

          DNS_Name = $dns}



          $Report | select VM_Name,Tools_Status,DNS_Name

          $Report | select VM_Name,Tools_Status,DNS_Name | Export-Csv C:\scripts\listvm.csv -NoTypeInformation