How do I better format the PowerShell output?
This is a really common question, and it doesn't always have a great answer.
First of all, consider this command:
Get-Process | Select-Object –Property Name,ID,VM,PM,CPU | Format-Table
Unless you specify a format command, as I've done in this case, PowerShell's native formatting system handles the PowerShell output for any command. You will get the same capabilities, and they're fairly primitive. If you're trying to produce awesome-looking reports for the boss, lower your expectations. PowerShell isn't designed for that.
HTML lets you do a bit more:
More robust approaches are available, and there are two free ebooks specifically on the topic. Both are listed here. One approach lets you produce HTML-based reports that can contain multiple sections, dynamic tables and much richer visual formatting. The result is still an HTML file, so it can go on an intranet Web server or be attached to an email.
The second approach inserts data into a SQL Server table (even a free Express edition) and uses SQL Server Reporting Services (also free) to produce rich heavily formatted reports. The second approach works well for trans-reports and other historical data, and it requires little programming to be successful.
About the author
Don Jones is a well-known and respected PowerShell expert and educator. He's co-author of three books on PowerShell (see PowerShellBooks.com for a list). You can find his content online, including his PowerShell Q&A forums, by visiting DonJones.com.
This was first published in April 2013