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.
Related Q&A from Don Jones, Contributor
If you don't need a GUI display, PowerShell can be hosted in several hosting applications so you can use cmdlets instead of a graphical input prompt.continue reading
With some simple configuration, admins can run a PowerShell script each time a computer starts with the help of the Task Scheduler GUI and cmdlets.continue reading
Each PowerShell version has different features made useful by add-ins and snap-ins, so admins have to pay attention to what features work where.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.