# 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.

```powershell
$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](https://www.ask-codey.com/glossary?category=powershell&level=2)

Updated: November 10, 2026

## In other subjects

- [Logical Operators in C#](https://www.ask-codey.com/glossary/logical-operators-c-sharp)
- [Logical Operators in Java](https://www.ask-codey.com/glossary/logical-operators-java)
- [Logical Operators in JavaScript](https://www.ask-codey.com/glossary/logical-operators-javascript)
- [Logical Operators in MongoDB](https://www.ask-codey.com/glossary/logical-operators-mongodb)
- [Logical Operators in Python](https://www.ask-codey.com/glossary/logical-operators)

Source: https://www.ask-codey.com/glossary/logical-operators-powershell
