Logical operators are used to evaluate two or more comparisons or other operations that produce a Boolean (true or false) result.
The following logic operators are available:
- And: -and
- Or: -or
- Exclusive or: -xor
- Not: -not and !
Logical operators are used to evaluate two or more comparisons or other operations that produce a Boolean (true or false) result.
The following logic operators are available:
The -and operator will return true if the values on the left-hand and right-hand side are both true.
For example, each of the following returns true:
$true -and $true
1 -lt 2 -and "string" -like 's*'
1 -eq 1 -and 2 -eq 2 -and 3 -eq 3
(Test-Path C:\Windows) -and (Test-Path 'C:\Program Files')