VMware Cloud Community
TheVMinator
Expert
Expert
Jump to solution

List VMs with Hostname Viewable

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?

Reply
0 Kudos
1 Solution

Accepted Solutions
nicholas1982
Hot Shot
Hot Shot
Jump to solution

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

Nicholas

View solution in original post

Reply
0 Kudos
1 Reply
nicholas1982
Hot Shot
Hot Shot
Jump to solution

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

Nicholas
Reply
0 Kudos