Save-Help | Taking on PowerShell one cmdlet at a time | Weekly Blog

Share this post:

This is a part of an on-going blog series written by Adam Gordon. Each week, Adam will walk you through a PowerShell command, showing you when and how to use each one. This week, Adam covers Save-Help. 

When to use Save-Help?

The Save-Help cmdlet downloads the newest help files for PowerShell modules and saves them to a directory that you specify.

This feature lets you update the help files on computers that do not have access to the Internet, and makes it easier to update the help files on multiple computers.

In Windows PowerShell 3.0, Save-Help worked only for modules that were installed on the local computer. Although it was possible to import a module from a remote computer or obtain a reference to a PSModuleInfo object from a remote computer by using PowerShell remoting, the HelpInfoUri property was not preserved, and Save-Help would not work for remote module Help.

In Windows PowerShell 4.0, the HelpInfoUri property is preserved over PowerShell remoting, which enables Save-Help to work for modules that are installed on remote computers. It is also possible to save a PSModuleInfo object to disk or removable media by running Export-Clixml on a computer that does not have Internet access, import the object on a computer that does have Internet access, and then run Save-Help on the PSModuleInfo object.

The saved help can be transported to the remote computer by using removable storage media, such as a USB drive. The help can be installed on the remote computer by running Update-Help.

This process can be used to install help on computers that do not have any kind of network access.

To install saved help files, run the Update-Help cmdlet. Add its -SourcePath parameter to specify the folder in which you saved the Help files.

Without parameters, a Save-Help command downloads the newest help for all modules in the session and for modules that are installed on the computer in a location listed in the PSModulePath environment variable.

NOTE: This action skips modules that do not support Updatable Help without warning.

The Save-Help cmdlet checks the version of any help files in the destination folder. If newer help files are available, this cmdlet downloads the newest help files from the Internet and then saves them in the folder. The Save-Help cmdlet works just like the Update-Help cmdlet, except that it saves the downloaded cabinet (.cab) files, instead of extracting the help files from the cabinet files and installing them on the computer.

The saved help for each module consists of one help information (HelpInfo XML) file and one cabinet (.cab) file for the help files each UI culture.

You do not have to extract the help files from the cabinet file. The Update-Help cmdlet extracts the help files, validates the XML for safety, and then installs the help files and the help information file in a language-specific subfolder of the module folder.

To save the help files for modules in the PowerShell installation folder ($pshome\Modules), start PowerShell by using the Run as administrator option. You must be a member of the Administrators group on the computer to download the help files for these modules.

This cmdlet was introduced in Windows PowerShell 3.0.

What version of PowerShell am I using for this blog?

Get the PowerShell Version from your machine:

$PSVersionTable

This command shows you the PowerShell version information on your machine.

How to use Save-Help?

Save the help for the DhcpServer module: (3 ways)

# Option 1: Run Invoke-Command to get the PSModuleInfo object for the remote DHCP Server module, save the PSModuleInfo object in the variable $m, and then run Save-Help.

$m = Invoke-Command -ComputerName RemoteServer -ScriptBlock { Get-Module -Name DhcpServer -ListAvailable }

Save-Help -Module $m -DestinationPath “C:\SavedHelp”

# Option 2: Open a PSSession — targeted at the remote computer that is running the DhcpServer module to get the PSModuleInfo object for the remote module, and then run Save-Help.

$s = New-PSSession -ComputerName “ITPTVRemote”

$m = Get-Module -PSSession $s -Name “DhcpServer” -ListAvailable

Save-Help -Module $m -DestinationPath “C:\SavedHelp”

# Option 3: Open a CIM session — targeted at the remote computer that is running the DhcpServer module to get the PSModuleInfo object for the remote module, and then run Save-Help.

$c = New-CimSession -ComputerName “ITPTVRemote”

$m = Get-Module -CimSession $c -Name “DhcpServer” -ListAvailable

Save-Help -Module $m -DestinationPath “C:\SavedHelp”

Three different ways to use Save-Help to save the help for the DhcpServer module from an Internet-connected client computer, without installing the DhcpServer module or the DHCP Server role on the local computer.

Install help for the DhcpServer module:

# First, run Export-CliXml to export the PSModuleInfo object to a shared folder or to removable media.

$m = Get-Module -Name “DhcpServer” -ListAvailable

Export-CliXml -Path “E:\UsbFlashDrive\DhcpModule.xml” -InputObject $m

# Next, transport the removable media to a computer that has Internet access, and then import the

PSModuleInfo object with Import-CliXml. Run Save-Help to save the Help for the imported DhcpServer module PSModuleInfo object.

$deserialized_m = Import-CliXml “E:\UsbFlashDrive\DhcpModule.xml”

Save-Help -Module $deserialized_m -DestinationPath “E:\UsbFlashDrive\SavedHelp”

# Finally, transport the removable media back to the computer that does not have network access, and then install the help by running Update-Help.

Update-Help -Module DhcpServer -SourcePath “E:\UsbFlashDrive\SavedHelp”

This set of commands shows how to install help that you saved in the prior example Save the help for the DhcpServer module: (3 ways) for the DhcpServer module on a computer that does not have Internet access.

Save help for all modules:

Save-Help -DestinationPath “\\ ITPTVRemote\ITPHelpShare”

This command downloads the newest help files for all modules in the UI culture set for Windows on the local computer. It saves the help files in the \\ITPTVRemote\ITPHelpShare folder.

Save help for a module on the computer:

Save-Help -Module ServerManager -DestinationPath “\\ ITPTVRemote\ITPHelpShare ” -Credential ITPTV/Adam

This command downloads the newest help files for the ServerManager module, and then saves them in the \\ITPTVRemote\ITPHelpShare folder.

When a module is installed on the computer, you can type the module name as the value of the Module parameter, even if the module is not imported into the current session.

The command uses the -Credential parameter to supply the credentials of a user who has permission to write to the file share.

Save help for a module on a different computer:

Invoke-Command -ComputerName ITPTV02 {Get-Module -Name SQL -ListAvailable} | Save-Help -DestinationPath “\\ ITPTVRemote\ITPHelpShare” -Credential ITPTV/Adam

These commands download the newest help files for the SQL module and save them in the \\ITPTVRemote\ITPHelpShare folder.

Because the SQL module is not installed on the computer, the sequence includes an Invoke-Command command that gets the module object for the SQL module from the ITPTV02 computer and then pipes the module object to the Save-Help cmdlet.

When a module is not installed on the computer, Save-Help needs the module object, which includes information about the location of the newest help files.

Save help for a module in multiple languages:

Save-Help -Module Microsoft.PowerShell* -UICulture de-DE, en-US, fr-FR, ja-JP -DestinationPath “D:\Help”

This command saves help for the PowerShell Core modules in four different UI cultures. The language packs for these locales do not have to be installed on the computer.

Save-Help can download help files for modules in different UI cultures only when the module owner makes the translated files available on the Internet.

Save help more than one time each day:

Save-Help -Force -DestinationPath “\\ITPTV3\AdminShare\Help”

This command saves help for all modules that are installed on the computer. The command specifies the -Force parameter to override the rule that prevents the Save-Help cmdlet from downloading help more than once in each 24-hour period.

The -Force parameter also overrides the 1 GB restriction and circumvents version checking. Therefore, you can download files even if the version is not later than the version in the destination folder.

Learn last week’s command: Out-Null.

Need PowerShell training? Check out ITProTV’s PowerShell online IT training courses.

Leave a Reply

Your email address will not be published. Required fields are marked *