Changes

Windows PowerShell 1.0 Functions

2 bytes removed, 20:51, 4 December 2008
Using Functions in a Pipeline
== Using Functions in a Pipeline ==
As discussed in previous chapters, Windows PowerShell allows cmdlets to be executed in a sequence, with the results from one cmdlet used as input to the next cmdlet in the pipeline chain. Pipelines are created by separating the cmdlets by the pipe character (|). In order to include a function in a pipeline it is necessary for that function to process the $input variable. This variable contains the results from the previous cmdlet or function in the pipeline. In the following example, a function named ''filelengths'' is designed to take the output from the ''dir'' cmdlet'', iterate through the ''$input'' variable and display the name and length of each file:
<pre>