A pipe passes data from one cmdlet to another. We used a pipe earlier to get all the properties of an object.
Basic Pipe Usage
For example, if you execute the following script, you’ll get all services sorted by their status:
Get-Service | Sort-Object -property Status
Outputting to Files
You can also use a pipe to output text to a file using a script like the following:
"Hello, World!" | Out-File C:\ps\test.txt
Multiple Pipes
You can use multiple pipes. For instance, the following script lists all services, with the first pipe excluding stopped services and the second pipe limiting the list to display names only:
Get-Service | WHERE {$_.status -eq "Running"} | SELECT displayname
# "$_." defines current element in the pipe