# switch Statement

*noun*

say it: **“SWICH STAYT-ment”** **/ˈswɪtʃ ˈsteɪtmənt/**

A part of a script that compares one value with a list of choices and runs the commands for each choice that matches.

## What is a **switch statement** in PowerShell?

A **switch statement** compares one value with a list of choices and runs the block of every choice that matches, with `default` for anything else. It ignores capital letters, and `-Wildcard` lets a choice be a pattern such as `'*.jpg'`.

```powershell
$choice = 'Q'
switch ($choice) {
    '1' { "Back up today's changes" }
    '2' { "Back up this week's changes" }
    'q' { 'Bye.' }
    default { "There's no $choice on the menu." }
}
# Bye.
```

## In a sentence

- “Sam's **switch statement** has a default block for any choice that isn't on the menu.”
- “The backup menu sends each answer to the right command with a **switch statement**.”

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

- [switch Statement in C#](https://www.ask-codey.com/glossary/switch-statement-c-sharp)
- [switch Statement in Java](https://www.ask-codey.com/glossary/switch-statement)
- [switch Statement in JavaScript](https://www.ask-codey.com/glossary/switch-statement-javascript)

Source: https://www.ask-codey.com/glossary/switch-statement-powershell
