Automatically update help-files for Windows PowerShell

With the introduction of Windows PowerShell 3.0 the help system was made updateable, which means we no longer have to wait for the next release of PowerShell to retrieve enhancements and bug fixes to the help system.

In an enterprise environment the help system typically needs to be centrally managed. There are several ways to accomplish this, for example we can use the “Set the default source path for Update-Help” Group Policy setting under Computer Configuration->Administrative Templates->Windows Components->Windows PowerShell to specify a default value for the SourcePath parameter:

image

In order to automatically update help files on computers running PowerShell 3.0 we can leverage scheduled tasks and distribute these through Group Policy.

1) On a computer running Windows Server 2012 or Windows 8, create a scheduled task that will periodically run the Save-Help cmdlet to save the files to a central location. This is not mandatory, but typically large environments have computers without internet access, thus it may be appropriate to download the help files to a central file server. In order to retrieve help files for all modules you should also install all management tools from Server Manager on the Windows Server 2012 computer running the scheduled task (using Remote Server Administration Tools if running Windows 8). Note that there is a HelpModules available which removes the requirement to install the management tools made by PowerShell MVP Joel “Jaykul” Bennett. You can read more in his blog post “Get-Help for Modules you don’t have installed”.

Create a new scheduled task which runs with the computer accounts credentials (SYSTEM):

image

Note: Remember to configure the file and NTFS settings for the central file share to allow Domain Computers to read the files.

Next, configure an appropriate time when the scheduled task should run:

image

Configure an action with the Start a program option:

image

Path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Arguments: -Command "& {Update-Help;Save-Help -DestinationPath '\\server\share\PowerShell\Help-files'}"

This will first run Update-Help to retrieve the newest help-files from Microsoft, and Save-Help to save the help-files from the local computer to the central file share.

Note: You could also use PowerShell to create the scheduled task which will run Save-Help, an example can be found in this blog post by Pat Richard.

2) On a Group Policy object which will affect all computers where you want the help files to be deployed, create a new scheduled task using Group Policy Preferences:

image

Create a new scheduled task which runs with the computer accounts credentials (SYSTEM):

image

Next, configure an appropriate time when the scheduled task should run (this should run shortly after the Save-Help scheduled task is run):

image

Configure an action with the Start a program option:

image

Path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Arguments: -Command “& {if (($PSVersionTable.PSVersion).Major -ge 3) {Update-Help -SourcePath ‘\\server\share\PowerShell\Help-files’}}”

You could also use Item-level targeting in order to create the scheduled task only on computers where PowerShell 3.0 is installed (if doing so, the if (($PSVersionTable.PSVersion).Major statement above can be dropped):

image

Here we test if the key named “3” exists under the PowerShell hive in HKLM:

image

Finally the task is created:

image

When future PowerShell versions is released, for example PowerShell 4.0, the Item level targeting must be updated to check for the “4” key in the registry as well. Alternatively an even more clever method to determine that the minimum version of PowerShell is 3.0 may be incorporated (please leave a note in the comments section below if you create one).

Resources