ForEach-Object — Basic UsageIT technician command center
PowerShell · Windows Administration

ForEach-Object — Basic Usage

Use ForEach-Object for a standard administrative task.

Copy-ready commandForEach-Object — Basic Usage
Get-Service | ForEach-Object { $_.Name }

Requirements and permissions

Requirements
Windows PowerShell 5.1 or PowerShell 7
Permissions
Varies by command
Last reviewed
2026-07-31

Examples

Basic Usage

Use ForEach-Object for a standard administrative task.

Get-Service | ForEach-Object { $_.Name }

Original command

Run an action for each pipeline object.

Get-Service | ForEach-Object { $_.Name }

Common errors

Command not found

Confirm Windows PowerShell 5.1 or PowerShell 7 is installed and available in your current shell.