Logical Operators
noun
say it: “LOJ-ih-kul OP-uh-ray-terz” /ˈlɑdʒɪkəl ˈɑpəˌreɪtərz/
Words that join true-or-false tests into one answer: and needs both to be true, or needs one, and not turns the answer around.
What are the logical operators in PowerShell?
Logical operators join tests into one answer. -and is True only when both tests are, -or when at least one is, and -not (or !) turns True into False and back.
$days = 7
$days -gt 0 -and $days -lt 31 # True
$days -lt 1 -or $days -gt 30 # False
-not ($days -gt 0) # False
In a sentence
- “Sam used logical operators to check that days is more than 0 and no more than 365.”
- “With logical operators, one if can ask about the file's date and its size at once.”
Level: Apprentice · More PowerShell terms at this level
Updated