ConvertTo-Html
noun
say it: “kun-VURT TOO AYCH-TEE-EM-EL” /kənˈvɜrt tu ˌeɪtʃˌtiˌɛmˈɛl/
A PowerShell command that turns objects into a web page with a table, one row for each object, ready to save and open in a browser.
What does ConvertTo-Html do?
ConvertTo-Html turns objects into a web page with a table: one row per object and one column per property. -PreContent adds text such as a heading above the table, and -Head a title and a little CSS. It hands back text, so save it with Set-Content and open the file in any browser: a report anyone can read without PowerShell.
$summary | ConvertTo-Html -Title 'October rentals' -PreContent '<h1>October rentals</h1>' |
Set-Content rentals-report.html
In a sentence
- “ConvertTo-Html turned the month's totals into a web page the shop owner could open on her phone.”
- “Sam added a heading with -PreContent and a little CSS with -Head before ConvertTo-Html wrote the report.”
Level: Journeyman · More PowerShell terms at this level
Updated