官术网_书友最值得收藏!

Using the Save-Help function

The useful help cmdlet Get-Help can provide useful information and examples. By default, PowerShell retrieves the help files from the Internet if they are not available locally.

In PowerShell Version 4 of Windows Management Framework, the function was introduced that made it possible to save the help files and import them to another server or client, which is great when a server or client is prohibited from having Internet access.

This can be done with the following few commands; these commands will be described in the How it works section.

How to do it...

Let's take a look at the following example to update the help files for the modules that has anything to do with Microsoft.PowerShell:

Get-Module –Name Microsoft.PowerShell*
Save-Help –Module Microsoft.PowerShell* –DestinationPath ` "C:\HelpFiles"
Update-Help-SourcePath "C:\Help" –Force
Update-Help -SourcePath "\\fileserver\HelpFilesShare" –Force

How it works...

Once the help files are downloaded, each module contains a XML and CAB file. These can be updated per module or all at once. This is a basic task to perform.

In the previous example, we are first retrieving the modules, which are available, that have a name Microsoft.PowerShell followed by something. Then, the help files are downloaded for these modules and saved in a local folder called Help.

If we do not specify any modules, all the help files for PowerShell will be downloaded to the specified folder.

Finally, these help files are then imported to another server or client, simply where they are needed using the Update-Help cmdlet.

As shown in the preceding example, the Update-Help function can either be pointing at a local folder or a UNC path or share.

Be aware that when running the Update-Help cmdlet, you may require to use the Run as administrator option or else it might not have the access needed to import the files into the system:

How it works...

Tip

Note that –DestinationPath and –SourcePath should be pointed to a folder and not to a file. The help files contain a pair of XML and CAB files per module.

A good idea would be to always keep these help files up to date and update them in the PowerShell profile to make sure that it's the current version.

See also

  • Using the help system
  • Using debugger functions
  • Creating custom objects
主站蜘蛛池模板: 宜兴市| 泰安市| 平度市| 郯城县| 丘北县| 九龙县| 广汉市| 澜沧| 繁昌县| 淮北市| 宁波市| 星子县| 桑植县| 陆川县| 安仁县| 新密市| 全南县| 高安市| 乾安县| 高平市| 新野县| 延津县| 徐闻县| 林口县| 苗栗县| 象州县| 东海县| 贡嘎县| 翁源县| 高碑店市| 元朗区| 醴陵市| 西乌珠穆沁旗| 安福县| 凤阳县| 河东区| 根河市| 阳东县| 鲁山县| 措勤县| 通化县|