Reputation: 157
I got this part of a script
| Where {$_.property = statement}
I would like to add another value so that it has to match both values, so the command is going to work kinda like this
| Where {$_.property -eq statement} & {$_.anotherproperty -eq anotherstatement}
anyone who can help?
Upvotes: 7
Views: 48733
Reputation: 144206
Logical and is done using -and
in powershell:
| Where {$_.property -eq statement -and $_.anotherproperty -eq anotherstatement}
Upvotes: 22
Reputation: 37222
The syntax you are looking for is -and
and -or
.
This example prints "Hello" if the variable a
is greater than 9 and less than 11.
$a = 10
if ($a -gt 9 -and $a -lt 11) { Write-Host "Hello" }
Please see the documentation for more details.
Upvotes: 4