Better PowerShell Help (Part 1)

by May 11, 2021

Many cmdlets provide rich online help, and you can automatically open the web page for a cmdlet by using Get-Help and submitting the -Online parameter:

PS> Get-Help -Name Get-Service -Online  

Each cmdlet also supports the common parameter -? which unfortunately only shows the much more limited built-in local help:

PS> Get-Service -?

    Get-Service [-ComputerName <System.String[]>] [-DependentServices] -DisplayName <System.String[]> [-Exclude 
    <System.String[]>] [-Include <System.String[]>] [-RequiredServices] []

However, with a simple trick you can tell PowerShell to also use the rich online help for the built-in parameter -?. Run this:

PS> $PSDefaultParameterValues['Get-Help:Online'] = $true  

This command automatically sets a new default value for the Get-Help -Online parameter, and since -? internally uses Get-Help, you now get rich online help for most PowerShell cmdlets simply by adding -? to the command name:

PS> Get-Service -?  

That’s really awesome so you may want to add the command to your auto-starting profile script. The path to this script can be found in $profile.CurrentUserAllHosts. It may not yet exist so you may have to create it.

However, there is one caveat: if the command has no online help, then you’ll now get an error message complaining that no online help was available. In an upcoming tip, we’ll address this separately.

Twitter This Tip! ReTweet this Tip!