Updating PowerShell help on an air-gapped machine

My virtual lab is disconnected from the real Internet so there’s no way to run Update-Help and get the latest help files. Thankfully there’s Save-Help which can be used to download the help files on another machine and then transfer them over.

By default Save-Help only downloads help files for modules installed on the machine it’s run on. That doesn’t cut it for me because my host machine (where I run Save-Help) doesn’t have as many modules as my guest machines. You can specify the names of modules to download help files for, but simply specifying the names does not work.

That’s because Save-Help looks for the module in files stored under the PSModulePath environment variable (example output from my machine below).

So what one really needs to do is provide the module itself to Save-Help. You have many options here: (1) install the module on the computer (not what you want to do usually!) or (2) connect to a computer which has the module, save that module object in a variable, and pass that on to Save-Help (you can do an Invoke-Command, or a New-PSSession, or a New-CimSession to the remote machine, then issue the Get-Module -ListAvailable -Name ... cmdlet to get the module object and pass back to the computer you are on) (see the first example from the Save-Help help page for more on this).

In my case since the host machine (with Internet) and guest machine (which needs the updated help files) have no network connection between them I’ll have to resort to other means. Enter Export-CliXML and Import-CliXML. When you connect to a remote machine and store the module object in a variable, what’s happening behind-the-scenes is that the object is converted to a text representation in XML. This preserves all the properties of the object but not the methods, and once this XML is passed to the remote computer it is converted back to an object (without the methods of course). If you can remote to a machine all this happens behind the scenes, but you can also do this manually via the Export-CliXML and Import-CliXML cmdlets – convert all the module objects on the target computer to their XML representation, copy these XML files to the computer with Internet access, convert them back to modules and download help files, then copy these help files to the target computer so Update-Help can add.

Thus on the virtual machine I do something like this:

Copy them to the host, change to that directory, and run:

Copy the downloaded files back to the virtual machine and do something like this:

That’s all!