PowerShell Reports, an interface with Bootstrap and jQuery
Tue, Nov 27, 2012I use PowerShell for as much of my job as possible. One of the most common things I’m asked to do is to provide some sort of report, and in some cases these reports need to be updated periodically.
Instead of emailing these reports out, I decided to string together a bit of JavaScript, static HTML, and an indexing job from PowerShell to create a semi-dynamic reporting interface for the reports my scripts create.
First, the site needs to know what reports are available to load. This is accomplished by exporting the list of files available to a JSON formatted file.
The reports are all basic HTML, created by the Exportto-HTML cmdlet.
The static site loads JavaScript that queries the JSON file containing the available reports. It uses this list to populate a sidebar. The sidebar links call another JavaScript function that loads the main content pane with the HTML from the report.
Finally, I threw in Data Tables (a jQuery plugin) to make the reports searchable and sortable.
The results? A site generated by PowerShell, served by Apache, and best viewed in Chrome.