Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Create a Master PowerShell Online Help Page

Posted on April 28, 2011July 2, 2013

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.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!
get-help get-wmiobject -online

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.

$data=Get-Command -CommandType Cmdlet | Where {$_.HelpURI} |Sort-object -property $Sort | 
Select Name,ModuleName,@{Name="Online Help";Expression={$_.HelpURI}}

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.

$data | ConvertTo-Html -Title "Online Command Help"  -CssUri $CSS -PreContent "<H2>PowerShell Online Cmdlet Help from $env:computername </H2>" 

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.

ForEach {
    #use a regex to find the url
    [regex]$urlRegEx="(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?"
    [regex]$tdRegEx="<td>$($urlRegex.ToString())</td>"
    
    #only get urls in the table
    if ($_ -match $tdRegEx)
    {
        #replace the link text with an html link
        $_ -match $urlRegEx | Out-Null
        #open each link in a new tab
        $link="<a href=$($matches[0])  target='_blank'>$($matches[0])</a>"
        $_.Replace($($matches[0]),$link)
    }
    else
    {
        #pass the line on
        write $_
    }
} | out-file -FilePath $file

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.

#view the file
Write-Verbose "Launching $file"
Invoke-item -Path $file

The script takes a few parameters.

Param(
[Parameter(Position=0)]
[ValidateNotNullorEmpty()]
[string]$file="$env:temp\PSOnlineHelp.html",
[string]$CSS="c:\scripts\sample.css",
[switch]$SortModule
)

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.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d