For the command-line administration tool, piping is an important concept. PowerShell also provides pipeline functionality to connect multiple commands in a single sequence line to achieve some of the more complex tasks.
Output to a CSV or XML file
As a system administrator, often look at some system status, such as: the current process of the system, the operation of services and so on. Although we can view it through the GUI application, it is sometimes necessary to look at the command line to output to a CSV or XML file, and then perform some analysis, comparison, and skills.
"Output to CSV": get-process | Export-csv
650) this.width=650; "title=" screen Shot 2017-02-10 at 10.52.50.png "src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvwkjpyuj5mgv5mlllshj0qzluthhxvxhhvgxlawnltdu5mfzyz2n4wu53r0dlzmv3ddzjvlvka01wq xjjz3zuzzy4dwtumznlt293vm5uwe1qvgzecfyzdy8w "alt=" screen Shot 2017-02-10 at 10.52.50.png "/>
Use Notepad to view the output files.
650) this.width=650; "title=" screen Shot 2017-02-10 at 11.00.25.png "src=" http://image2.135editor.com/cache/remote/ ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvwkjpyuj5mgv5mlllshj0qzluthhxvxhhvgxlawnltdu5mejnuglium5yawj6veg2zgg1awf5y1n4w gjbcjlqvu9bdmxmmlv0rmxybueyawfbrmrvtkr5shk3m0evma== "alt=" screen Shot 2017-02-10 at 11.00.25.png "/>
Comparing the results of executing the get-process command in the console, you can see that the information exported to the CSV file is much more than the information displayed on the screen. This is due to limited screen capacity, and PowerShell only displays the most important information on the screen.
650) this.width=650; "title=" screen Shot 2017-02-10 at 11.05.41.png "src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvwkjpyuj5mgv5mlllshj0qzluthhxvxhhvgxlawnltdu5mfqynnvqnmrduepvdvfon0zjzg5pahpvd 3drrjfdawnwbudodevyejnzmkrxchy3cnjiejjgzwcvma== "alt=" screen Shot 2017-02-10 at 11.05.41.png "/>
"Output to XML": get-process | Export-clixml
"Clixml" is dedicated to PowerShell.
650) this.width=650; "title=" screen Shot 2017-02-10 at 11.12.17.png "src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvwkjpyuj5mgv5mlllshj0qzluthhxvxhhvgxlawnltdu5me9fyvzrcxbwbu5fve9yemo3wjzurtdhm 3czdhfjz0hqemvldwhvqxpabhfmy093wjfkre1szy8w "alt=" screen Shot 2017-02-10 at 11.12.17.png "/>
View the XML file in Notepad.
650) this.width=650; "title=" screen Shot 2017-02-10 at 11.13.56.png "src=" http://image2.135editor.com/cache/remote/ ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvwkjpyuj5mgv5mlllshj0qzluthhxvxhhvgxlawnltdu5mfzxwmyyemljv21gog5eqmliv2f0u0s3c gljbwvpykxpt1vxbnpjvnhzylhpyutfzvlzvuq4s1npyklmqs8w "alt=" screen Shot 2017-02-10 at 11.13.56.png "/>
View with IE.
650) this.width=650; "title=" screen Shot 2017-02-10 at 11.17.30.png "src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvwkjpyuj5mgv5mlllshj0qzluthhxvxhhvgxlawnltdu5mg1lt1zrdvdlmlnkddbld3kxbnjvrflls Gngy3lpynzstm9jrnbit3bytlflawjydhpywvbvzmf3lza= "alt=" screen Shot 2017-02-10 at 11.17.30.png "/>
Second, transfer to the printer
"Command": get-process | Out-printer
Outputs the command result directly to the default printer.
650) this.width=650; "title=" screen Shot 2017-02-10 at 11.37.02.png "src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvwkjpyuj5mgv5mlllshj0qzluthhxvxhhvgxlawnltdu5meppy0u5tnb2rvkzcg1waenpylvizldnm g9ezufpyk9hredmuu03b2lhzutsbuvpdwprbgiwdw1tzfevma== "alt=" screen Shot 2017-02-10 at 11.37.02.png "/>
Because the test system does not have a physical printer installed, the command stores the results directly to the PDF document.
Whether the command can form a meaningful pipeline is a certain rule, and listen to the tell.
This article from the "China Polar Road" blog, reproduced please contact the author!
PowerShell Learning notes-pipelines