Welcome to Sign in | Join | Help
in
Home Blog Forums

The Lazy Admin

Output PowerShell to HTML

Sponsor


PowerShell offers a number ways to export data, one of the easiest to read is in an HTML file. The ConvertTo-HTML cmdlet allows you to export your data requests to a portable HTML file.

In the following examples I am going to take one of the previous commands we looked at in an earlier PowerShell article called Get-Process which lists all processes running. We are going to pipe the output from that command to the ConvertTo-HTML cmdlet and specify a location to save it to.

Get-Process | ConvertTo-HTML | Set-Content c:\process-report.html

We can take this one step further and sort the table so it is a little easier on the eyes.

Get-Process | ConvertTo-HTML name, path | Set-Content c:\process-report.html

Finally we can add a title with the -title switch.

Get-Process | ConvertTo-HTML name, path -title "Process List" | Set-Content c:\process-report.html

Go ahead and try it!





Published Thursday, December 07, 2006 6:22 PM by rodney.buike
Filed under:

Comments

No Comments
Anonymous comments are disabled


All postings are provided "AS IS" with no warranties, and confer no rights.
Microsoft product screen shot(s) reprinted with permission from Microsoft Corporation.