VMware Cloud Community
philk33
Enthusiast
Enthusiast
Jump to solution

Get VM's with status toolsOK and HW Version not v11

Hello,

I'm not too great with combining where statements in powercli. Do I have to create variables and then perform my Get-VM action?

Here is what I have, and it doesn't work. I assume because the Where-Object doesn't allow an additional Where statement that isn't related to Where-Object?

Connect-VIServer -Server xx.xxx.xx.xxx

Get-VM | Where (Where-Object {($_.ExtensionData.Guest.ToolsStatus -eq "toolsOk")} -and (Where Version -NE "V11"))

Obviously it is wrong, can someone help me out? Is it even possible?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | Where-Object {$_.ExtensionData.Guest.ToolsStatus -eq "toolsOk" -and $_.Version -NE "V11"}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | Where-Object {$_.ExtensionData.Guest.ToolsStatus -eq "toolsOk" -and $_.Version -NE "V11"}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos