Object Pipelines

Windows PowerShell provides a new interactive model that is based on objects, rather than text. One major advantage of using objects is that it makes it much easier to pipeline commands, that is, to pass the output of one command to another command as an input.

The command that receives an object can act directly on its properties and methods without any conversion or manipulation. You can refer to properties and methods of the object by name, rather than calculating the position of the data in the output.

In the following example, the result of a Get-Scenario command is passed to a Get-Hosts command. The pipeline operator (|) sends the result of the command on its left to the command on its right, and the output is sent to a Format-Table command.

PS> Get-Scenario "File Server*" | Get-Hosts | FT -AUTO

Scenario       Name            Role         Parent     State    IP             Port

--------       ----            ----         ------     -----    --             ----

File Server 1 192.168.1.152  Master     --            Running   192.168.1.152   25000

File Server 1 192.168.1.153  Replica  192.168.1.152   Running   192.168.1.153   25000

File Server   192.168.1.152  Master    --             Stopped   192.168.1.152   25000

File Server   192.168.1.153  Replica  192.168.1.152   Stopped    192.168.1.153   25000