# ForEach-Object

say it: **“for-EECH OB-jekt”** **/fɔrˈitʃ ˈɒbdʒɛkt/**

Runs code once for each object in the pipeline.

## What is **ForEach-Object**?

`ForEach-Object` runs a script block once for each object in the pipeline. `$_` is the current object.

```powershell
Get-ChildItem *.txt | ForEach-Object { "$($_.Name) is $($_.Length) bytes" }
```

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

Updated: November 17, 2026

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