Create an HTML page from one or more PowerShell objects.

Syntax        ConvertTo-Html [[-head] [] ] [[-title] ] [[-body] [] ]         [-CssUri ] [[-property] [] ]            [-As { | LIST}] [-inputObject ]               [-PreContent []] [-PostContent []] []       ConvertTo-Html [-Fragment] [[-property] [] ]            [-As { | LIST}] [-inputObject ]               [-PreContent []] [-PostContent []] []Key    -head         Text to include in the  element of the HTML output.        default = "HTML TABLE"         If you specify -Head, the -Title parameter is ignored.    -title         Text to include in the  element of the HTML output.    -body         Text to include in the  element of the HTML.    -Fragment        Generate only an HTML table. The HTML, HEAD, TITLE, and BODY tags are omitted.    -inputObject         The objects to represent as an HTML table.         A variable that contains the objects or a command/expression        that gets the objects.        If you submit multiple objects, such as all of the services on a computer,        ConvertTo-Html will display the properties of the collection / array.         To display the individual objects, use the  to        pipe the objects to ConvertTo-Html one at a time.   -As         Format the object as a table or a list. Valid values are TABLE or LIST.    -CssUri         The Uniform Resource Identifier () of the cascading style sheet        The CSS URI is included as a style sheet link in the output.    -property         Properties of the input object to appear in the HTML table.            -PreContent []       Text to add before the opening 
 tag.    -PostContent []       Text to add after the closing 
 tag.            :       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,       -OutBuffer -OutVariable.

The object property names appear as HTML table column headings.

Examples

Display the date as HTML on the console :

PS C:\>  | convertto-html

Save the system processes to C:\processes.html

PS C:\>  | ConvertTo-Html name,path,fileversion | Set-Content c:\processes.htm

Save the system services to C:\services.html

PS C:\>  | ConvertTo-Html -Title "Services" -Body "<H2>The result of get-service</H2> " -Property Name,Status  >  c:\services.html

Save the system services to C:\services.html and format in color (example from Hung Yuwu ):

PS C:\>  | ConvertTo-Html -Title "Services" -Body "<H2>The result of get-service</H2> " -Property Name,Status | 

foreach {if($_ -like "*<td>Running</td>*"){$_ -replace "<tr>", "<tr bgcolor=green>"}elseif($_ -like "*<td>Stopped</td>*"){$_ -replace "<tr>", "<tr bgcolor=red>"}else{$_}} > c:\services.html

Save the system services to C:\services.html and format with css, then open the HTML page with Invoke-Item:

PS C:\>  | ConvertTo-Html -CssUri "SS64.css" > c:\services.html

PS C:\>  c:\services.html

Get events from the "Windows PowerShell" event log, select only the ID, Level, and Task properties and format as HTML:

PS C:\>  -log "Windows PowerShell" | convertto-html -property id, level, task

“If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack” ~ Winston Churchill

Related:

 - Produce a clixml representation of a PowerShell objects

 - Export to Comma Separated Values (spreadsheet)
 - Invoke an executable or open a file