# throw

*noun*

say it: **“THROH”** **/θroʊ/**

A PowerShell keyword that stops a script or function at once with an error showing a message you write.

## What does **throw** do in PowerShell?

`throw` stops the script right there with an error, and the error's message is the text you give it. Use it when a script finds something it can't carry on without, such as a tool that isn't installed, so the person running it reads what to do instead of a confusing failure later.

```powershell
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
    throw 'Install git first: this project needs it.'
}
```

## In a sentence

- “When git was missing, the check task used **throw** to say Install git first.”
- “A message given to **throw** should tell the reader what to do next.”

Level: Journeyman · [More PowerShell terms at this level](https://www.ask-codey.com/glossary?category=powershell&level=3)

Updated: November 10, 2026

## In other subjects

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

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