Examples for NewHtmlReport PowerShell module
Some sample reports and the code snippets that made them:
-
myVMHostReport.htm, report with some "highlighted" rows, giving an example of different styling for data items whose values are out of the "norm" range or not of the expected value:
PS C:\> New-HtmlReport -Title "My VMHost Report" -PreContent "<H3>VMHosts Info</H3>" ` -PostContent "<SPAN CLASS='footerInfo'>Generated $(Get-Date -Format ` 'yyyy-MMM-dd HH:mm:ss \G\M\Tz')</SPAN>" -TableCaption "highlighted rows are of VMHosts that ` are not in 'Connected' state" -InputObject (Get-VMHost | Select Name, ConnectionState, ` MemoryTotalGB, @{n="bDoRowHighlight"; e={$_.ConnectionState -ne "Connected"}}) -RoundNumber ` -NumDecimalPlace 1 | Out-File -Encoding utf8 c:\temp\myVMHostReport.htm
-
myDatastoreClusterReport.htm, report with highlighted rows again, but with taking the input objects for the report from pipeline:
PS C:\> Get-DatastoreCluster | Select Name, @{n="CapacityTB"; e={$_.CapacityGB/1kb}}, ` @{n="FreeSpaceTB"; e={$_.FreeSpaceGB/1kb}}, SdrsAutomationLevel, @{n="bDoRowHighlight"; ` e={$_.SdrsAutomationLevel -ne "FullyAutomated"}} | New-HtmlReport -Title "My ` DatastoreCluster Report" -PreContent "<H3>DatastoreCluster Info</H3>" -PostContent ` "<SPAN CLASS='footerInfo'>Generated $(Get-Date -Format 'yyyy-MMM-dd HH:mm:ss \G\M\Tz')` </SPAN>" -TableCaption "highlighted rows are of DatastoreClusters where SdrsAutomationLevel ` is not 'FullyAutomated'" -RoundNumber -NumDecimalPlace 1 | Out-File -Encoding utf8 ` c:\temp\myDatastoreClusterReport.htm
-
myCombinedReport.htm, report with multiple tables from multiple sources of data, each with independent sortability:
PS C:\> New-HtmlReport -Title "My Combined Report" -PostContent "<BR />",(New-PageBodyTableHtml ` -InputObject (Get-Cluster) -Property Name, EVCMode, VsanEnabled) -InputObject (Get-Datastore) ` -Property Name, FreeSpaceGB, CapacityGB -RoundNumber -PreContent "<H3>Combined report of ` datastores and clusters</H3>" | Out-File -Encoding utf8 c:\temp\myCombinedReport.htm