- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Get-View Guest.Hostname property returning null
Can anyone tell me why this one liner only returns the VM name and not the Guest Host name?
Get-View -ViewType VirtualMachine -Property Name -Filter @{"Guest.HostName" = ".*$prompt.*"} | Select @{N='VM Name';E={$_.Name}}, @{N='Guest Host Name';E={$_.Guest.HostName}} | ft -wrap -auto
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
$_.Guest.Hostname is not the ESXi host, it's the name of the VM. You could see the host by selecting Get-VMhost -id $_.Runtime.Host, since you're using Get-View.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for the late reply. I understand that $_.Guest.Hostname returns the VM machine name. My problem is that the query is returning nothing in the second part of my select statement. The first column should return the VM name, and the second column should return the VM machine name. I don't know why it's not returning the latter.
And just to clarify, I'm not interested in the ESXi host name. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Figured it out, I was missing the Guest.HostName property when defining parameters of get-view:
Get-View -ViewType VirtualMachine -Property Name, Guest.HostName