PowerShell Command Piping

In real life, people use pipes to transfer goods (for example, oil) from one end to another. PowerShell pipes are similar because they enable you to easily transform, modify, or pass the result of one cmdlet to another.

Let’s say we want to list all site collections in a SharePoint farm. Get-SPSite cmdlet displays all the site collections, but in large farms it might returns hundreds or thousands of results. If Get-SPSite is combined with a filter command (over pipe), it will return only specific site collections that require attention.

Get-SPSite | Where {$_.Url –eq "http://portal.companyabc.com"}

By using the pipe “|”, we see results (all site collections) of the Get-SPSite cmdlet that are passed to the Where pipe, ...

Get Microsoft SharePoint 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.