ReportHTML, Cmdlets Usage, Help & Examples

Report created on Jun 8, 2017 07:30 PM
Why we wrote this PowerShell is an amazing tool for gathering, collecting, slicing, grouping, filtering and collating data. However, trying to show that information or several sets of it on one report is not as easy. A few years we ago built our own solution, we created a set of HTML reporting functions. I have been using these functions for years to help myself, my team and customers to deliver Powershell data to people that just need the details and not a CSV file or a code snippet. Weve now decided to make these available to the rest of you.
Original Credits This code was originally borrowed from Alan Renouf for a vSphere healthcheck report by Andrew Storrs and myself for a more dynamic reporting style, being able to create reports on the fly with minimal effort.
Recent Credits Jennifier Han, Giovanni Fleres, Chris Speers, Keith Ellis, Blake and Moep
Running Reports These reports, once built can be scheduled to run, dropped on a file share emailed or saved to an Azure Storage Blob.
This Help Report Will walk through several examples of how to use the functions to generate different types of reports.
Beta Help File Please note this help is in a draft state introduced Get-HTMLDataTable fucntion to consume HTML 5 Data tables features. Included additional java scripts and CSS styles Added Custom footer text to Get-HTMLPageClose -FooterText 'Your text here'.
Created Functions for Heading Get-HTMLHeading, added CSS H1 to H7.
Added PowerShell Logo, usage 'PowerShell' in get-HTMLPageOpen Updated 'Corporate' Logo and 'Alternate' logo files Added dynamic columns function Get-HTMLColumnOpen.
Example Usage 'Get-HTMLColumnOpen -ColumnNumber 1 -ColumnCount 2' minor fixes Sleeps removed from module, Axis Labels added to bar chart, few logic errors corrected.
Added Get-HTMLContentTableAadvanced Added This Change Log Added Totals to get-HTMLContentTable and associated help content another fix to save-HTMLReport so it can handle a null reportpath.
Moved Html Help file logic to a nested psm1 file.
In addition to Creating ReportHTMLHelpers to start building more reports this module
was updated in conjunction with publishing Run-ReportAzureRBAC Minor Fixes, Major addition a Help Report. run Get-HTMLReportHelp Changes to allow for more flexible customization, use Chart JS for charting, working in Azure Automation and
now support HTML5 Tabs Awesome changes here for flexibility with CSS, Logos, Chart creation and more. Hopefully there will be less
major changes from here once legacy cmdlets are removed. Feedback always welcome Changes to add functionality for Custom CSS files and changed export to be HTML file type. The CSS and
Javascript files are now present in the module directory allowing for ease of manipulation
and customization. Get-HTMLOpen and Get-HTMLClose still present in module but
can be replaced with Get-HTMLOpenPage and Get-HTMLClosePage. Changes (non Breaking) to add functionality for Custom CSS files and changed export to be HTML file type.
Get-HTMLOpen and Get-HTMLClose still present in module but can be replaced with
Get-HTMLOpenPage and Get-HTMLClosePage. Thanks to Moep for fix to table row color with default values. Added Bar chart function and -testchart switch fixed HTML Close working on charting options fixed HTML Close.

Creating headings Get-HTMLHeading -headerSize 1 -headingText 'This is heading 1'
Heading Tag 1
 $rpt += Get-HTMLHeading -headerSize 1 -headingText "This is heading 1" 
Heading Tag 2
 $rpt += Get-HTMLHeading -headerSize 2 -headingText "This is heading 2" 
Heading Tag 3
 $rpt += Get-HTMLHeading -headerSize 3 -headingText "This is heading 3" 
Heading Tag 4
 $rpt += Get-HTMLHeading -headerSize 4 -headingText "This is heading 4" 
Heading Tag 5
 $rpt += Get-HTMLHeading -headerSize 5 -headingText "This is heading 5" 
Heading Tag 6
 $rpt += Get-HTMLHeading -headerSize 6 -headingText "This is heading 6" 

This is heading 1

This is heading 2

This is heading 3

This is heading 4

This is heading 5
This is heading 6

Functions Each function return HTML code, the parameters you send in will be return with HTML code.
Building an Array To build a report create an array object and add parts of your report together.
Eg, create an array variable $Rpt = @()
Next add to the array.
$RPT += get-htmlpageopen -title "Welcome"
Open / Close Although these functions help you with HTML its still HTML. HTML uses tags and everything you open you must close
Get-HTMLContentOpen -HeaderText, creates a section header. You can then add other functions and code. However you must eventually add get-HTMLContentClose.
Using Indenting is an easy way to keep track of what tag your in.
Saving Reports The Array need to be saved to a file, there are a couple of options for this.
You can save the array to a file using set-content.
$rpt | set-content -path "c:\temp\MyReport.html"
You can use the Save-HTMLReport Function. There is also a save to storage azure blob option
Building Report Code
 $rpt = @()
$rpt += Get-HTMLOpenPage -TitleText "ReportHTML" 
	$rpt += Get-HTMLContentOpen 
		$rpt += Get-HTMLContentText -Heading "Header" -Detail "Detailed Information" 
	$rpt += Get-HTMLContentClose 
$rpt += Get-HTMLClosePage  
Custom Report Footer
 $rpt += Get-HTMLClosePage -FooterText "Enter Your Custom Text Here" 
Saving a Report - Write Array to file
 $rpt | set-content -path "c:\temp\MyReport.html"  
Set-Content -Value $rpt -path "c:\temp\MyReport.html"  
Invoke-item "c:\temp\MyReport.html" 
Saving a Report - Use the builtin function (1 Liner Options)
 Save-HTMLReport -Reportcontent $rpt -ReportPath c:\temp -ReportName "MyReport" -showreport
Save-HTMLReport -Reportcontent $rpt -ReportPath c:\temp -ReportName "MyReport.html" 
Save-HTMLReport -Reportcontent $rpt -ReportPath c:\temp -ReportName "MyReport" 
Save-HTMLReport -ShowReport 
$SavedFile = Save-HTMLReport -ShowReport  
Saving a Report - Save To Azure Storage Blob
 Save-HTMLToBlobStorage -Needs an Azure Account #More to come