# For Each Thing: \`foreach\`

The foreach statement runs the steps in its braces once for each item in a list, with a variable you name holding this item, so a script renames 30 files or 200 with one loop and can decide about each one with an if.

![Cheat sheet for the lesson For Each Thing: \`foreach\`: The foreach statement runs the steps in its braces once for each item in a list, with a variable you name holding this item, so a script renames 30 files or 200 with one loop and can decide about each one with an if.](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/4eb2142f43cf4eab997333b7e5f7477d.webp)

- Category: PowerShell
- Level: Apprentice
- Tags: foreach Loop, foreach-object, loop, powershell, rename-item
- Updated: November 10, 2026

Source: https://www.ask-codey.com/cheat-sheets/powershell-foreach-loop-cheat-sheet
