Automation

 View Only
  • 1.  List VMs with Hostname Viewable

    Posted Nov 04, 2017 03:50 AM

    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?



  • 2.  RE: List VMs with Hostname Viewable
    Best Answer

    Posted Nov 04, 2017 05:07 AM

    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