Skip navigation

Making HTML Reports in PowerShell

You're probably aware of PowerShell's ability to make HTML output:

Get-Process | ConvertTo-HTML | Out-File processes.html

But did you know that the shell can do more complex reports that include multiple pieces of information? Start like this:

$a = Get-Process | ConvertTo-HTML -Fragment 
$b = Get-Service | ConvertTo-HTML -Fragment
$c = Get-WmiObject -class Win32_OperatingSystem | ConvertTo-HTML -Fragment -Property *

Repeat that for as many bits of information as you want, putting each into a different variable. Finish up like this:

ConvertTo-HTML -body "$a $b $c" | Out-File report.html

Putting all of your variables inside those double quotes. Voila, a multi-table report. Using other parameters of ConvertTo-HTML (like -PreContent and -CssUri) you can add section headings, apply formatting, and more.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish