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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access