简体   繁体   中英

Simple Powershell where filter not working

Dears,

Executing the below powershell command returns no value even though it should return some matched values. Am i missing something?

 get-vm | select VMName ReplicationMode, State | Where-Object  {(state -eq 'Running') -and (ReplicationMode -eq 'None')}

Is there a way to fix this without using "$_" syntax?

Thanks,

Why do you not want to use $_ ?

$_ represent each occurrence of your selection.

I did my own example. Where is the problem?

 Get-Process | select Id, ProcessName | Where-Object {($_.ProcessName -eq 'chrome') -and ($_.Id -gt 30000)}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM