Aboodnet
Aboodnet

Reputation: 143

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,

Upvotes: 0

Views: 2806

Answers (1)

Nando
Nando

Reputation: 120

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)}

Upvotes: 1

Related Questions