ForEach-Object is most often used as a loop (of sorts). For example, the following command works on each of the results from Get-Process in turn:
Get-Process | ForEach-Object { Write-Host $_.Name -ForegroundColor Green }
In the preceding example, a special variable, $_, is used to represent each of the processes in turn.
ForEach-Object may also be used to get a single property, or execute a single method on each of the objects. For example, ForEach-Object may be used to return only the Path property when using Get-Process:
Get-Process | ForEach-Object Path