# foreach Loop

*noun*

say it: **“for-EECH LOOP”** **/fɔrˈitʃ ˈlup/**

A loop that runs the same steps once for each item in a list, such as every file in a folder.

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

A **foreach loop** runs the steps in its braces once for each item in a list. The variable you name before `in` holds this item on each pass. Use it in a script; in a pipeline, use `ForEach-Object`.

```powershell
foreach ($system in 'fuel', 'power', 'radio') {
    "Checking $system... go"
}
# Checking fuel... go
# Checking power... go
# Checking radio... go
```

## In a sentence

- “A **foreach loop** renamed all thirty telemetry files from .tmp to .log.”
- “Inside the **foreach loop**, $sensor holds one sensor's file on each pass.”

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

- [foreach Loop in C#](https://www.ask-codey.com/glossary/foreach-loop)

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