Effectively using Help in PowerShell is your key to scripting success! Help in PowerShell 3 and 4 revolves around three cmdlets: Get-Help, Save-Help, and Update-Help.
Contents of this article

Out of the box, help in PowerShell is incomplete. To see what I mean, type Get-Help Get-Command on a new machine. In the remarks section of the output, you should see the following error message about partial help files.

Get-Help

Get-Help

To ensure that the PowerShell help files are updatable, Microsoft only ships the bare minimum that is needed for help. Although it might seem odd, let’s explore Update-Help and Save-Help first. Then we will jump back to Get-Help (and cover a really great hotkey trick).

Update-Help ^

The first command that you should run in PowerShell is Update-Help. This cmdlet ensures that you have the most complete and up to date PowerShell help files on your computer. When you run Update-Help, PowerShell will enumerate every module stored in the PSModulePath environment variable.

PSModulePath environment variable

PSModulePath environment variable

Each module contains a Help URL which PowerShell uses to locate the online help files. These files are compared against the local help files; any newer files are downloaded to replace the local outdated files.

Things are a little more complicated than they seem because most modules are stored in C:\Windows\System32\WindowsPowerShell\v1.0. If you try to run Update-Help, you will likely receive an error stating that Update-Help was unable to update certain modules.

Update-Help

Update-Help

By default, PowerShell runs as a standard user. The Update-Help cmdlet doesn’t have the ability to replace the protected files listed in the error above. The trick is to run PowerShell as an administrator. The easiest way to do this is through the WINX menu on Windows 8.1.

As a best practice, regularly run Update-Help. You can schedule a regular update by creating a scheduled task. You can also use Group Policy Preferences to deploy a scheduled task to any IT computer. If you have remote or disconnected computers, downloading help files from Microsoft might be impractical. This takes us to the Save-Help cmdlet.

Save-Help ^

When using the Update-Help cmdlet, you might have noticed the –sourcepath parameter. This parameter allows you to specify an internal network share as your help file location. Save-Help allows you to download the help files to a network location. This command has changed a bit with PowerShell 4.

The syntax is simple and the only requirement is that the network folder must exist beforehand. On a network share (such as on a script repository), create a new folder named HelpFiles. In PowerShell, run Save-Help –DestinationPath “\\SERVER\SHARE\HelpFiles\”. When the command completes, your folder will be populated with each help .CAB file. You can even automate this task by setting a scheduled task to download updated files on a regular basis.

Help .CAB files

Help .CAB files

Administrators in your organization can now run Update-Help –SourcePath “\\SERVER\SHARE\HelpFiles\”. You can make this step even easier by prepopulating the –SourcePath value with Group Policy!

In the Group Policy Management Console, edit a GPO and navigate to Computer Configuration/Policies/Administrative Templates/Windows Components/Windows PowerShell. Enable Set the default source path for Update-Help and plug in your HelpFiles UNC. After a GPUpdate, machines will use your network location to download updated help files!

Get-Help ^

No matter your PowerShell experience, Get-Help will be one of your most used cmdlets. The cmdlet Get-Help can be accessed in a multitude of ways. The first is by running Get-Help CMDLET. For example, Get-Help Get-Command.

Get-Help Get-Command

Get-Help Get-Command

Personally, I learn the best when I can see actual examples of command being used. Get-Help can show you this by using the parameter –examples. To show you what I mean, Get-Help Get-Command –Examples would display 14 detailed samples!

Get-Command

Get-Command

To retrieve the entire help for a specific command, you can run Get-Help CommandName –full. If you are using PowerShell ISE, you are probably familiar with the Command pane. After searching for a cmdlet in this pane, you can press the blue question mark button to pull the full cmdlet help file in an external window.

Help in PowerShell ISE

Help in PowerShell ISE

But my favorite (and easiest) way to get help is found in the PowerShell ISE scripting pane. After typing a cmdlet, press F1 on your keyboard to launch a windowed help file.

Help with F1

Help with F1

As long as your typing cursor is touching the command, F1 will launch a help window for that command.

Summary ^

Help in PowerShell is extremely robust! Update-Help ensures that you have the latest documentation. Save-Help allows you to centralize help files for quicker access. The many iterations of Get-Help allow you to learn a PowerShell cmdlet in the most comfortable method for you.

0
3 Comments
  1. Greg J 7 years ago

    this is the single best article I have read on powershell. you should really write more tips like this.

    0

  2. Author

    Thanks Greg! At the top of the page, click More - PowerShell. If you have any specific articles that you would like to see, just leave me a comment.

    0

  3. Vivek 4 years ago

    I agree with Greg, You should write more, like tutorials for PowerShell. I am a newbie and would like to learn it from Beginning to Very Advance level, like managing multi forest level environment.

    Let me know if u have some thing like that

    0

Leave a reply

Please enclose code in pre tags

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2021

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account