If you want to query information from one computer, you use the Windows Management Instrumentation (WMI) to query that information. In the case you want to query a series of computers, you have to provide a list of computer names and such. This is a completely different query. How do you run the query command? Get the list and run a command to query WMI. Well, this is where you will need to pipeline. In this tutorial, you will learn how to use Pipelines to streamline commands in PowerShell.
If you have not already done so, click open Windows PowerShell ISE.
What is a pipeline? A pipeline occurs when one takes the output of one command and directs it to the input of another command. Essentially, it takes out the additional processes by stringing the commands together. Otherwise known as piping the output of one command to another.
Piping a command to another would be ran much like the following in Windows Command Prompt:
ipconfig | find "IP Address"
The particular sequence uses the ipconfig to list the IP configurations of all the network adaptors in the system and pipes it out to the find the command, then it is then filtered and displays only the few lines that contain the string "IP Address". The issue with this method, is that it relies on manipulating the text output of the command before that.
PSH uses the same convention of using the pipe (|) character to denote piping the output of one command to another, however in the background, the behavior is different. PSH doesn't pass text amongst commands, it passes objects. The arrangement is vital because the receiving command is able to access the various attributes of the object directly instead of trying to parse out strings to interpret the data. The importance of objects instead of text? Text may change on you, objects, due to their structure, will not change on you.
Pipelining actually saves a lot of time and prevents having to be the middleman between commands. Join us next time for additional Windows PowerShell tutorials! Till then…