Prof. Powershell

PowerShell Help Line

Prof. Powershell demonstrates how to easily pull up the most-recent cmdlet help online in a PowerShell window.

A great feature in PowerShell is the ability to always get the most current cmdlet help by using the –Online parameter.

PS C:\> help get-eventlog -online

Core PowerShell cmdlets should have an online URI that will open up and display the most up-to-date published help. Many other cmdlets from Microsoft as well as third-party vendors also support -Online. What about making that the default behavior? In PowerShell 3.0 and later you can create a preference to do just that.

The built-in $PSDefaultParameterValues variable represents a hashtable. The key takes the format "cmdlet:parameter." You specify the value. The variable exists by default but will be undefined. Here's how to "turn on" the -Online parameter.

PS C:\> $PSDefaultParameterValues.add("get-help:online",$True)

If you like this, you can put the line in your PowerShell profile. Now when you run Get-Help without any parameters, you will automatically get online help. Because -Online is part of its own parameter set, you can still run commands like this:

PS C:\> help get-eventlog –full
PS C:\> help get-eventlog -showwindow

You can also use this default value setting in the PowerShell ISE. Or, you can configure the ISE to not use local help. Go to Tools – Options – General Settings and clear the check box for "use local help content instead of online content" as I did in Figure 1.

[Click on image for larger view.]  Figure 1.

In reality, this only applies when getting help in the script console. In the command console if you run Get-Help, the ISE will still use local help unless you use the PSDefaultParameterValue. The option in Figure 1 applies when you select a cmdlet name in the script editor, or have the cursor anywhere in the name and press F1. Local help displays in a pop-up window like you get with –ShowWindow. When configured for online help, your browser should open automatically to the online help page. This option will persist between ISE sessions. Nothing you need to do in your profile.

You can also set this in the ISE from the console pane:

PS C:\> $psise.options.UseLocalHelp = $True

Here I've gone ahead and set it back to local help.

But be aware, if -Online is always on, you will get an error if you try something like this:

PS C:\> help process

You will have to remember to turn off the online parameter at least momentarily.

PS C:\> help process –online:$false

Still, if you always want online help everywhere, add the PSDefaultParameterSetting to the current user all hosts profile script ($profile.CurrentUserAllHosts) and set the ISE option.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular

SharePoint Watch

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.