I want to retrieve a set of virtual machine names based on a custom attribute. I have a custom field called Alert Level and I want to list only those servers with an alert level of 4 so that i can automatically shut them off during a power outage.
This is what I have so far:
Get-VM | Select Name -ExpandProperty CustomFields | Where {$_.key -eq "Alert Level"} | Where {$_.value -eq 4}
This seems to get me the namem, the field and the value but all I want is the name.
Any ideas?
Try this
Get-VM | where{$_.CustomFields["Alert Level"] -eq 4} | Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try this
Get-VM | where{$_.CustomFields["Alert Level"] -eq 4} | Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You are the master. Thank you.