PowerShell, Scripting, vNext, Windows 8
comments 5

PowerShell 3.0: Save-Help woes and solution

PowerShell 3.0 introduced updateable help feature because of which there is no in-box help. We need to use Update-Help and Save-Help cmdlets to update the help content from Microsoft download sites.

Now, this is a great feature to help people get up-to-date help from Microsoft. However, there are a couple of complaints problems I had.

  1. I never got Save-Help to work behind a proxy.
  2. Most of the machines in the lab setup have no Internet connectivity and/or always isolated from outside world. So, to get the help updated on these systems, I need to try a lot of workarounds like copying the module files to another system that has Internet connectivity and then using Save-Help to get the help content to a removable drive and then transport it back to the lab. There are quite a few new modules in Windows 8 Server and this method won’t scale.

So, I decided to see how exactly Save-Help works. It is simple!

If you look at the module manifest in PowerShell 3.0, each module has a HelpInfoUri which points to an online source to download the content. But, this is not exactly the same URL you can use to download the help content. It essentially redirects to a download.microsoft.com URL and then Save-Help uses its magic to download the right files. All this magic is in the module manifest itself. This will become clear if you look at the files that are downloaded using Save-Help.

It should be clear from this that there is a standard pattern in the file naming. So, if we know the correct URL from the HelpInfoUri from the module manifest, we know what files to download and from where.

So, the following script uses this logic to get the files from Internet and at the same time, resolves the two issues I mentioned above.

All you need is to save the above code as a .psm1 file and use the functions within this module to get the help content. This is how you need to use this module:

Generate a moduleXML for offline download purpose

First, we need to export the information we need to build the right URLs to an XML file. I am calling moduleXML. All you need to do is, load this module on a Windows 8 Server or client system or PowerShell 3.0 system to export the module name, module GUID, and HelpInfoUri to an XML file. This is done using:

Once we have the XML file, we can use this module XML file anywhere to download the help content from any or all of the modules listed in the XML.

You can use the module.xml I generated on my Windows Server 8 beta system.

Here is how this module solves the issues I mentioned earlier.

Works behind a proxy

As soon as you load the module, it detects if you are behind a proxy and prompts you for the credentials required for proxy authentication. 

Offline download of help for any module

To download the help content for the modules, this module uses the moduleXML created using the New-ModuleXML function. This is how you can use this:

This is it. This will download all available help content for the modules listed in the XML to a local folder. If you just want to download it for only one module, you can do so using:

This is it. At the moment, not all modules seem to have the online help content. So, for some of the modules, you will just see a message that the help content is not available.

At the moment, this script is very raw. I have not included lot of error checking. Do let me know if you find any issues or have a suggestion.

Filed under: PowerShell, Scripting, vNext, Windows 8

by

Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.