PowerShell also has a few useful filtering cmdlets:
Where-Object (alias where and ?)—Participates in a pipeline by helping to narrow down the objects passed along the pipeline based on some specific criteria.
ForEach-Object (alias foreach and %)—Participates in a pipeline by applying a scriptblock to every object passed along the pipeline.
By looking at a few files and a directory contained within a test directly, we can easily demonstrate the use of both cmdlets:
PS C:\book> dir Directory: Microsoft.PowerShell.Core\FileSystem::C:\book ...