Generating HTML reports

CSV files are nice, but HTML files are more impressive. This section will show you how to create nice-looking HTML files from your reports. PowerShell gives you the ConvertTo-Html cmdlet to do this. The syntax of this cmdlet is as follows.

The first parameter set creates an entire HTML page:

ConvertTo-Html [[-Property] <Object[]>] [[-Head] <String[]>]  [[-Title] <String>] [[-Body] <String[]>] [-As {Table | List}] [-CssUri <Uri>] [-InputObject <PSObject>] [-PostContent <String[]>]  [-PreContent <String[]>] [<CommonParameters>]

The second parameter set creates only an HTML table and omits the HTML, HEAD, TITLE, and BODY tags:

ConvertTo-Html [[-Property] <Object[]>] [-As {Table | List}] [-Fragment] [-InputObject <PSObject>] [-PostContent ...

Get Learning PowerCLI - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.