Create HTML reports

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

ConvertTo-HTML will convert text information into simple HTML, which can then be saved to disk. These reports will work fine, even though they are pretty ugly. Using just a simple HTML style sheet, your HTML reports will look a lot better:

$style = @'
<style>
body { background-color:#EEEEEE; }
body,table,td,th { font-family:Tahoma; color:Black; Font-Size:10pt }
th { font-weight:bold; background-color:#AAAAAA; }
td { background-color:white; }
</style>
'@

Get-Process |
ConvertTo-HTML Name, Company, CPU -head $style |
Out-File $home\report.htm
ii "$home\report.htm"

Twitter This Tip! ReTweet this Tip!


Posted May 25 2010, 08:00 AM by ps1

Comments

jbruns wrote re: Create HTML reports
on 05-26-2010 9:51 AM

Any chance of publishing the 2 HTML code samples in a text file?

The carriage return line feeds are being dropped and the email examples are coming through as a graphic image.

Thx

Copyright 2012 PowerShell.com. All rights reserved.