PowerShell to change the way F1 Help document commands get online documents _powershell

Source: Internet
Author: User

Applies to PowerShell or later versions

Starting with PowerShell 30, the PowerShell itself does not have a bundle of help documents. The user has to use the command update-help to update the PowerShell help document and download it to the locally protected PowerShell folder. is protected because regular users cannot perform the update command.

The next time you want to see a help document without a command, you can simply use the online version. The-online parameter opens the online Help document for the get-process command in the browser (this operation relies on the network)

Copy Code code as follows:

Ps> Help Get-process-online

Once the help document has been installed, it will be easy to view the help in PowerShell ISE: simply click on the command, select it, and press F1 shortcut.

If you look closely, you will find that the inside of the F1 just calls the help command. So, if you want to change the behavior of F1 and let it open the online Help document, you may temporarily write a function like the following:

Copy Code code as follows:

function Get-help ($Name)
{
Get-help $Name-online
}

Then the code would be a dead loop. Within your new function Get-help calls it itself, it is a no way out, endless recursion. In order for your function to work really, we need to let the get-help inside the function invoke the Get-help command of PowerShell itself. All we need to do is append its own component (module) name to the previous command:
Copy Code code as follows:

function Get-help ($Name)
{
Microsoft.powershell.core\get-help $Name-online
}

After you run the above function, in PowerShell ISE, selecting a command and then pressing F1,ise will also help you open the Help document for the command in the browser.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.