# while Loop

*noun*

say it: **“WYL LOOP”** **/ˈwaɪl ˈlup/**

A loop that keeps repeating its steps for as long as a condition stays true, checking before each time round.

## What is a **while loop** in PowerShell?

A **while loop** checks its condition before every pass and repeats the steps in its braces for as long as the answer is True. Something inside the loop must change the answer, or it never ends.

```powershell
$fuel = 40
while ($fuel -lt 100) {
    "Fuel at $fuel%"
    $fuel += 20
}
# Fuel at 40%
# Fuel at 60%
# Fuel at 80%
```

## In a sentence

- “Sam's **while loop** kept adding fuel until the tank reached 100.”
- “The launch script waits in a **while loop** until go.txt appears.”

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

- [while Loop in C#](https://www.ask-codey.com/glossary/while-loop-c-sharp)
- [while Loop in Java](https://www.ask-codey.com/glossary/while-loop-java)
- [while Loop in JavaScript](https://www.ask-codey.com/glossary/while-loop-javascript)
- [while Loop in Python](https://www.ask-codey.com/glossary/while-loop)
- [while Loop in Unix](https://www.ask-codey.com/glossary/while-loop-unix)

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