PowerCli - cannot filter Virtual Machines by VMHost property

I'm experimenting for the first time PowerCli on my VSphere environment. I'm trying the Get-Vm filtering the results in this way and it's working fine:

Get-Vm | where MemoryGB -eq "8"

but if I try the same syntax, filtering by VMHost property, I don't get any result:

Get-Vm | where VMHost -eq ""

But I have a lot of machines on the host, why it's not working? I can see it if I use this syntax that filters the text output in the end:

Get-Vm | select name,vmhost | findstr -i .30

what I'm doing wrong?



  • The VMHost property that you're referring to is actually a VMHost object, so you may have to filter something like Get-VM | where {$_.VMHost.Name -eq ''} in order to do a string vs. string comparison.