ForEach-Object - Powershell 2.0 CmdLet
Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.
More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.
ForEach-Object
Short description Performs an operation against each of a set of input objects. Syntax ForEach-Object [-Process] <ScriptBlock[]> [-Begin <scriptblock>] [-End <scriptblock>] [-InputObject <psobject>] [<C Description The ForEach-Object cmdlet performs an operation on each of a set of input objects. The input objects can be piped t o the cmdlet or specified by using the InputObject parameter. The operation to perform is described within a script block that is provided to the cmdlet as the value of the Proc ess parameter. The script block can contain any Windows PowerShell script. Within the script block, the current input object is represented by the $_ variable. In addition to using the script block that describes the operations to be carried out on each input object, you can provide two additional script blocks. One, specified as the value of the Begin parameter, runs before the first in put object is processed. The other, specified as the value of the End parameter, runs after the last input object i s processed. The results of the evaluation of all the script blocks, including the ones specified with Begin and End, are passed down the pipeline.