# do-until Loop

*noun*

say it: **“DOO un-TIL LOOP”** **/ˈdu ənˈtɪl ˈlup/**

A loop that runs its steps first and then checks, repeating until a condition becomes true, so it always runs at least once.

## What is a **do-until loop** in PowerShell?

A **do-until loop** runs the steps in its braces first and checks its condition at the end, stopping as soon as the condition is True. Because the check comes last, it always runs at least once, which suits trying again. `do { } while ( )` goes on while its condition is True instead.

```powershell
$tries = 0
do {
    $tries++
    $answered = Test-Connection ground-station.invalid -Count 1 -Quiet
} until ($answered -or $tries -eq 3)
"Tries: $tries, answered: $answered"
# Tries: 3, answered: False
```

## In a sentence

- “Sam used a **do-until loop** because the first try has to happen before there's anything to check.”
- “The **do-until loop** tries the ground station up to three times.”

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

Updated: November 10, 2026

Source: https://www.ask-codey.com/glossary/do-until-loop
