In the previous tip, we created cheat sheets for PowerShell commands and turned them into HTML reports that could be opened in a browser, and printed. That worked well, but the output page wasn’t very fancy. With just a few HTML styles, your command list is ready for prime-time, and you can use the technique in this example to “beautify” any other HTML table you may create from PowerShell using ConvertTo-Html:
# adjust the name of the module # code will list all commands shipped by that module # list of all modules: Get-Module -ListAvailable $ModuleName = "PrintManagement" $Title = "PowerShell Print Management Commands" $OutFile = "$env:tempcommands.html" $StyleSheet = @"
$Title"@ $Header = "
$title" Get-Command -Module $moduleName | Get-Help | Select-Object -Property Name, Synopsis | ConvertTo-Html -Title $Title -Head $StyleSheet -PreContent $Header | Set-Content -Path $OutFile Invoke-Item -Path $OutFile