PowerShell: Save-Help for Modules that Aren’t Installed on the Local Computer without Copying Files

In my last blog article on this subject, I showed how to copy the PowerShell module manifest file from a server with the module you want to download the help for to the local computer to trick it into thinking the module was installed locally, but copying files can get messy and isn’t really a robust way of accomplishing that task.

The first method I used did get me thinking about this process though. If all the Save-Help cmdlet does is to look for the Module manifest file somewhere in the PowerShell Module Path, then why not point the $env:PSModulePath variable to the location of the modules on the servers you want to save the help for instead of copying the manifest files?

On the Windows 8 computer I’m using, $env:PSModulePath looks like this by default:

As with my previous blog on this subject, this process is unsupported. I’m going to add the UNC path location to the modules on my domain controller, SQL server, and IIS web server to this variable. You could backup the current value of the variable by piping it to the Out-File cmdlet, but the changes to it will only exist for the lifetime of the current PowerShell session so saving the current value is unnecessary.

I ended up with a space between each path, so I’ll use the replace method to remove them:

Nothing currently exists in the location I plan to save the help to:

I used the Save-Help cmdlet and specified the -DestinationPath parameter. I also used the -Force parameter since I’d already tested this a couple of times and if you want to download the help more than once a day, it’s necessary, but since several modules are duplicated in the path now, I wouldn’t recommend using the -Force parameter otherwise you’ll end up downloading the same help files multiple times and just overwriting them.

I can see that the help was downloaded for several modules that are not installed on the local computer:

Here’s where I verified the help files were actually saved to the specified destination. The first two in the list, ActiveDirectory and ADDSDeployment, are examples of modules that don’t exist on the local computer:

Update 11/9/12:
I’ve crossed out a phrase in the first paragraph because we’re actually downloading the help to a network share (not to the local computer). The goal here is to download and save the PowerShell help files to a network share from a machine that has Internet access. This allows servers that do not have Internet access to update their PowerShell help by specifying the network share as the source path when running the Update-Help cmdlet.

The problem I’m working-around in this blog is being able to download the help files for modules that do not exist on the computer the Save-Help cmdlet is being run from, but do exist on servers that don’t have Internet access. I would also recommend reading part 1 of this blog article which gives more background information on the problem.

µ

2 Comments

  1. Peter Kriegel

    Here are my 3thrd Article with the Updateable-HelpProxy Module.
    I have mentioned your Aticles in there.
    For me, the original function from the module by Ravikanth Chaganti did not work.
    So i have modified and extended the original module
    Also Invoke-WebRequest cmdlet contained in the PowerShell 3.0 was not compatible with our proxy.
    My module therefore uses internally the Get-Webfile (wget for PowerShell) by Joel Bennett to download the files.
    This function I added the proxy properties.
    The function, and thus the function Save-Help proxy attempts to find the proxy automatically and thereby are the credentials of the current user used.
    With a single sign on proxy and automatic settings can therefore first of all try to dont provide any proxy parameter informations.
    The two major functions in the module are well documented (with my bad English 😉 ).

    Cheers Thank you for your good work Peter Kriegel
    http://www.admin-source.de/BlogDeu/548/save-help-im-unternehmen-fuer-offline-rechner-auch-mit-einem-proxy-benutzen

    Reply
  2. stangm

    So what do I do if Save-Help doesn’t work because of a lack of proxy support?

    Reply

Leave a Reply

%d bloggers like this: