Create a Master PowerShell Online Help Page

As I hope you know, PowerShell cmdlets can include links to online help. This is very handy because it is much easier to keep online help up to date. To see online help for a cmdlet use the -online parameter.

I decided to take things to another level and create an HTML page with links to online help

I created a relatively simple script called New-OnlineHelpPage.ps1. The script uses Get-Command to retrieve a cmdlet name, it’s module or snapin and it’s help link.

This expression filters out cmdlets without an online link. By default the script sorts by cmdlet name but if you use the -SortModule parameter, it will sort by module or snapin. Get-Command treats them as the same. The data is piped to ConvertTo-HTML to create the HTML report.

The function lets you specify a CSS file path which is stored in $CSS and I include a sample one in the download below. But now for the fun part. The help url looks like a link but it isn’t actionable. Remember that ConvertTo-HTML doesn’t create a file, it creates HTML which means I can intercept it and use a regular expression to find the URL and replace it with HTML code that turns it into a link. At the end of the process I finally pipe the HTML to Out-File to create the report.

The last step is to launch the HTML page using Invoke-Item. This will launch the file with whatever application is associated with the file extension you specified.

The script takes a few parameters.

The file it creates is stored in you TEMP folder by default. The script will process any cmdlet loaded in your PowerShell session so you can add snapins like PowerCLI or modules like ActiveDirectory and get those links as well. What you end up with is a single page with links to all the online help.

Even if this isn’t of use, I hope you picked up a little knowledge about Get-Command and ConvertTo-HTML. You can download a zip file with my script and a sample CSS file here.

New Event Report Revised

Last year I posted an update to an old Mr. Roboto script that was an update to an even older VBScript. Still with me? My last revision leveraged the new Get-WinEvent cmdlet to create an HTML report of recent error activity on one or more computers. The problem was that I didn’t account for older computers that don’t support Get-WinEvent. I finally have a version that does. Continue reading

Get Some Style

Windows PowerShell has many ways to present and store information. You can display it to the screen, write it to a file, send it to a printer, create an CSV or XML file or even a pretty HTML report. The ConvertTo-HTML cmdlet underwent a significant facelift for v2.0 and is a popular cmdlet. But I don’t think admins know how to fully take advantage of the cmdlet or have the right tools. Continue reading