Export (0) Print
Expand All

Pipelining

 

Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1, Exchange Server 2007

Topic Last Modified: 2006-08-15

Pipelining in the Exchange Management Shell is the act of one cmdlet using the output of another cmdlet when it performs an operation. Pipelining is accomplished by using the pipe "|" symbol. All verbs in the same noun-cmdlet set can use piped information from another command. Some noun-cmdlet sets also let you pass data through the pipeline to another noun cmdlet set.

The use of pipelining to string together the actions of two or more cmdlets gives the Exchange Management Shell the power of composition, which lets you take smaller components and convert them into something more powerful. For example, you can use one cmdlet to gather data, pass that data to a second cmdlet to filter the data to a subset, and then pass that data to a third cmdlet to act on the subset only.

For example, the following command uses pipelining to move all the mailboxes on Server1 to the Executives database on Server2 by using the Move-Mailbox cmdlet, based on output that is piped from the Get-Mailbox cmdlet:

Get-Mailbox -Server Server1 | Move-Mailbox -TargetDatabase Server2\Executives

You can also use pipelining to process data that is output by a cmdlet. For example, for a list of all processes where the HandleCount property of the process is larger than 400, you can run the following command:

Get-Process | Where { $_.HandleCount -gt 400 } | Format-List

In this example, the Get-Process cmdlet passes objects to the Where-Object cmdlet. The Where-Object cmdlet picks out the objects that have a property called HandleCount with a value larger than 400.

In this example, the HandleCount property is preceded by the $_ variable. This variable is created automatically by the Exchange Management Shell to store the current pipeline object. The Where-Object cmdlet then sends these objects to the Format-List cmdlet to be displayed.

The use of structured objects, instead of text, is one of the most exciting capabilities of the Exchange Management Shell. The use of structured objects forms the basis of a powerful compositional model of administration.

For more information about structured objects, see Structured Data.

To report errors, you can use the error pipeline. The error pipeline lets you report errors while a command runs. This means that you don't have to wait until the command has finished running or to put the error information in the standard result pipeline. The Write-Error cmdlet writes its arguments to the error pipeline.

For more information about pipelining, run the following command in the Exchange Management Shell:

Get-Help About_Pipeline
 
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft