Create HTML System Reports

Share |

Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus

13 Free SQL Tools from Idera

Free Ebook: Mastering Powershell

ConvertTo-HTML is a great way of creating system reports because you can combine information gathered from different sources into one report. The following code will create a report with service information that is gathered from Get-Service, operating system overview returned by WMI, and installed software read directly from the registry:

$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; }

& {
"<HTML><HEAD><TITLE>Inventory Report</TITLE>$style</HEAD>"
"<BODY><h2>Report for '$env:computername'</h2><h3>Services</h3>"
Get-Service |
Sort-Object Status, DisplayName |
ConvertTo-HTML DisplayName, ServiceName, Status -Fragment
'<h3>Operating System Details</h3>'
Get-WMIObject Win32_OperatingSystem |
Select-Object * -exclude __* |
ConvertTo-HTML -as List -Fragment
'<h3>Installed Software</h3>'
Get-ItemProperty Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* |
Select-Object DisplayName, InstallDate, DisplayVersion, Language |
Sort-Object DisplayName | ConvertTo-HTML -Fragment
} | Out-File $home\report.hta
ii $home\report.hta

Twitter This Tip! ReTweet this Tip!

Posted May 26 2010, 08:00 AM by ps1
Copyright 2012 All rights reserved.