$txtColor = 'AliceBlue' $file = "$env:temp\TempHTML.htm" $HTMLHeader =@" <style> BODY{background-color:white;} TABLE{border-width: 1px;border-style: solid;border-color: black; border-collapse: collapse;margin-left:auto; margin-right:auto;} TH{border-width: 1px;padding: 1px;border-style: solid; border-color: black;background-color:$txtColor} TD{border-width: 1px;padding: 1px;border-style: solid; border-color: black;background-color:$txtColor} </style> "@ #Example $title= 'Service Information' Get-Service | Select-Object Status, Name, DisplayName,Starttype | ConvertTo-HTML -head $HTMLHeader -body "<center><H2>$title</H2><Font=Verdana></Center>" | Out-File $file Invoke-Expression $file
This a modification of something I picked up on the web. It allows you to export to an HTML file with a centered table and centered title. Any number of properties in the data are made into auto-sized columns.