Weekend Scripter: Use PowerShell to Update Help on Remote Servers


Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to update Windows PowerShell Help on remote servers.

Microsoft Scripting Guy, Ed Wilson, is here. One of the great things about any version of Windows PowerShell is the Help that comes with the product. Having access to Get-Help is great whether I am working on a server or a workstation. I will admit that even having worked with Windows PowerShell as long as I have, I do not remember every cmdlet, every nuance, every switch and parameter available. I don’t think anyone does.

This greatness is actually a double-edged sword. Beginning with Windows PowerShell 3.0, the Help is not installed by default; and therefore, it must be updated. This is also a good thing because it helps ensure that the Help is up-to-date, complete, and accurate.

A problem occurs, however, when I have servers that do not have access to the Internet. How do I deal with that situation?

It is tempting to not have any Help on the systems at all. After all, I am pretty good with Windows PowerShell, so I can more than likely do what I need to do. But it is much better if I do have access to Help on the servers. So what do I do? Luckily, Windows PowerShell has an answer. The answer is Save-Help and Update-Help.

Download Help

The first thing I need to do is to download the Help files. This means I need a computer that has access to the Internet. In addition, if I want to get Help for a specific module, it is easiest if I have that module installed because then I will automatically get the Help for that module.

It makes sense for me to download the files directly to a shared location. The first thing I do is delete any files that may be in my shared Help location. I do this to keep from running to issues with trying to overwrite existing files. Here is the command I use to delete the files:

Remove-Item C:\Shared\UpdateHelp -Include *.* -Recurse

Now I download the Help files for all of the modules installed on my server. Here is the command I use:

Save-Help -Module * -DestinationPath \\dc1\share\UpdateHelp

After I download the Help files, I can go to the folder and see what (if anything) happened. Here, I see the Help files:

Image of folder

Install the Help files on remote servers

Now I can install the Help files on my remote servers. To do this, I use Windows PowerShell remoting to run the Update-Help cmdlet on each of the remote servers. When I call Update-Help, I specify the path to my Help shared folder. Here is the command I use from my workstation:

Invoke-Command -ComputerName S1, S2 { Update-help -SourcePath \\dc1\Share\UpdateHelp -force }

I did not need to specify credentials because I am signed in with an account that has Admin rights on the remote servers. If I was not signed in as an Admin, I would need to specify the –Credential parameter and supply credentials for the command.

I use the Invoke-Command cmdlet again to see if I did, in fact, get the Help files updated. Here is the command I use:

Invoke-Command -ComputerName S1, S2 { get-help get-help }

This command is simple, and I simply check to see if I have the Help files for Get-Help. Previously, I did not—now I do. Sweet! It works.

Now I can use the Task Scheduler to run these commands on my various systems, and keep Help automatically updated. Because all of these commands are one-liners, it is really easy to do. Sweet.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy 

Comments (4)

  1. tommymaynard says:

    I suspect the Remove-Item cmdlet was supposed to use the UNC for it’s path, as well.

  2. Tim says:

    Great article! But how would you go about getting help for a remote server and you do not have the modules installed in the client computer that has access to the Internet?

  3. Thanks you for your article, very nice

  4. Thanks you for your article, very nice

Skip to main content