Reports must be functional and readable, but if you are not the only one consuming these reports why not to make them look good too?
Fancy reports can be generated using PowerCLI - actually the capability is provided by PowerShell - by using the ConvertTo-Html cmdlet which generates an HTML output.
The trick to generate these good looking reports is to consider them as a webpage, that will be generated by script, to which a Cascading Style Sheet (CSS) will be applied.
Page is composed by an header, a CSS and a body. CSS part is the most important for our purpose because it will describe how output will be styled. Body section of the page will contain correct div IDs assignation and all statistics composing our report and in this example I get infos regarding Datacenter, Cluster and VMs. Of course you can include in the report whatever you want.
This is the expected result:
Here's the code. As usual I've uplaoded it to my GitHub page: Fancy Reports.ps1
$PageBoxOpener, $ReportVmHost, $BoxContentOpener, etc. variables are used to delimit the divs upon which CSS style will be applied.
To better understand how this works the schema of the page generated by the script above can be represented as:
<div id='title'> PowerCLI Reporting </div> <div id='subtitle'> Report generated: $(Get-Date) </div> <div id='box1'> #Box Delimiting Report <div id='boxheader'> #First Report Header Get-VMHost $LocationName </div> <div id='boxcontent'> #First Report Table Get-VMHost ... </div> <div id='boxheader'> Get-Cluster $ClusterName </div> <div id='boxcontent'> Get-VMHost ... </div> <div id='boxheader'> Get-VM $ClusterName </div> <div id='boxcontent'> Get-VMHost ... </div> </div>