No offense to the console window or a text file, but sometimes it’s hard to beat HTML as an output device (for one thing, HTML gives you more formatting options and flexibility). Fortunately the ConvertTo-Html cmdlet makes it very easy to view Windows PowerShell output in a Web page. For example, this command uses the Get-Process cmdlet to retrieve information about all the processes running on the computer. The output from Get-Process is piped to the ConvertTo-Html cmdlet, which creates an HTML table out of that data. In turn, that table is piped to the Set-Content cmdlet, which saves the information as a Web page (C:\Scripts\Test.htm). That sounds like a lot of work, yet the command is as simple as this:
1 |
Get-Process | ConvertTo-Html | Set-Content c:\scripts\test.htm |