Windows PowerShell - Pipeline Symbol (|) or (¦)PowerShell Scripting - Pipeline Symbol (|) or (¦)Pipelining could almost be described as PowerShell's signature tune. Windows PowerShell encourages you to join two statements so that the output of the first clause, becomes the input of the second clause. If it helps to streamline your task, you can have more than one join per statement, thus the output of the second clause, becomes the input of the third element. To separate these individual clauses, Microsoft chose the pipe symbol, '|' sometimes called the bar key. To give you a physical analogy, think of an oil pipeline with lots of cylinders joined together with hollow ring seals. Or better still, an assembly line to produce a bottle of beer!
One common use of pipelining is the 'Where' clause, for example: I also use the pipe for research, my technique is to place '|' between the object I am investigating and get-Member. For example, get-service | get-Member. Windows PowerShell Pipeline Topics
♣ Pipeline (|) or (¦) - Possible Display ConfusionWhen typed in notepad the pipeline symbol looks like a solid vertical bar |, but when typed at the Windows PowerShell PS> prompt, it looks like ¦. On my keyboard the key in question is next to the Z, however I have seen keyboards where the key is next to numeric 1 on the top row. Once you press the correct key, you get a pipe or bar symbol like this: |. Michael Babbitt writes to say that on his American keyboard the pipe is above the \ (backslash) and next to the right hand 'Shift' key. To be clear, this pipe (|) symbol corresponds to ASCII 124, and not ASCI 0166. Test by holding down the Alt key, then type the number 124 on the numeric pad, finally, let go of the Alt key you should get a |. Pipeline ExamplesHere are four examples showing how to join two or more clauses to form a continuous PowerShell production line. Check the logic. See how the output from the first clause becomes the input for the second statement. Example 1:
get-Process. Let us discover the members and properties Example 2: Example 3: Example 4: The last example has two pipe symbols. You may observe that either 'where-object', or plain 'where', work equally well. Also, -gt means greater than.
Guy Recommends: SolarWinds Engineer's Toolset v10
|
|||||
|
|
|
|
Home Copyright © 1999-2009 Computer Performance LTD All rights reserved Please report a broken link, or an error. | |