O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Filtering Cmdlets

PowerShell also has a few useful filtering cmdlets:

Image 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.

Image 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required