I'm trying to find the name of a VM by it's id. I tried the following but it did return any results. Any thoughts?
Get-VM | Where { $_.Id -eq "VirtualMachine-vm-36780/3000" }
Take off the /3000 part.
Also, don't use where-object, the get-vm cmdlet has an Id parameter.
Get-VM -Id VirtualMachine-vm-2277
Author of the upcoming book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
I understand it's generally bad practice to use the where-object when you have a specific value in mind, but if you aren't 100% on the vm id, you should try using the -match switch to use a regular expression.
For example:
Get-VM | Where { $_.Id -match "VirtualMachine-vm-36780.*" }
or something like that 😛