process { foreach ($elementin$Object) { "Processing received element $element..." } } }
请注意如何通过参数调用函数:
1 2 3 4 5 6 7 8
PS C:\> Process-Data -Object 1 Processing received element 1...
PS C:\> Process-Data -Object 1,2,3,4 Processing received element 1... Processing received element 2... Processing received element 3... Processing received element 4...
您也可以通过管道传送信息:
1 2 3 4 5
PS C:\> 1..4 | Process-Data Processing received element 1... Processing received element 2... Processing received element 3... Processing received element 4...