Chapter 12. Tips and tricks for creating complex or advanced HTML reports with PowerShell
One of PowerShell’s most common uses is to collect data and then generate reports from that data, which makes it an excellent tool. PowerShell can export data for reporting purposes to a number of different formats, including CSV, XML, and HTML. But typically you can only export the data in a raw form, and you’ll have to use other tools to make the report look pretty.
In this chapter I’ll show you ways to improve the quality of an HTML-based report using PowerShell tips and tricks, without needing to depend on other tools. By means of a Systems Inventory report example you’ll see what you can achieve with a small amount of extra knowledge.
To create the Systems Inventory report I’ll use some standard PowerShell techniques for scripts, but the focus of the chapter will be on PowerShell tips in HTML. Throughout the chapter I’ll be putting together the following sections to build up the script, and I’ll include the complete code at the end of this chapter:
- Script parameters and help
- A begin block to include generating the HTML header and report image
- A process block to generate the queries that will produce the report data for each computer included in the report
- An end block to join together the various HTML code parts and export them to a file