PowerShell Basics: How to use PowerShell Help?

Learn All About Getting Help for PowerShell Commands.
parveensingh-headshot
Parveen
5 minutes read
June 2, 2021

Table of Content

Share this

Twitter
LinkedIn
Reddit

Even after using the PowerShell language to write scripts and perform the automation, I find it challenging to find exactly what commands I need to use how to use those commands appropriately.

With any other suitable programming language, you will find some built-in help functionality to guide you through the instructions. It may simply describe what the commands are or could be full of example scenarios to get you up and running in no time.

In this article, I’ll cover all the aspects of how to get help from PowerShell’s Get-Help command without even leaving your terminal.

Prerequisites

If you are not familiar with PowerShell commands and syntax, be sure to check out the following article to recap the basics of PowerShell:

If you choose to follow along, you should have a Windows machine with PowerShell already installed, or you can use this article to install the PowerShell.

What is Get-Help in PowerShell

PowerShell Get-Help cmdlet provides a rich set of information and instruction on any command, function module, or script. The resulting information includes Name, Syntaxes, Alias, and Examples for using the command.

In your terminal, run the command Get-Help to display the information about what the command is all about.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/925337b4-30dc-459f-a603-36932ad7b4a8/01-gethelp.png
Run Get-Help PowerShell

Review the Examples section that displays the common way you can use the help command to find information using other modules or commands.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9d44610f-e5a7-487a-8e40-d6f0b1e2fc85/02-helpexample.png
Get-Help Examples

Updating PowerShell Help Module

PowerShell uses local storage to save the help information and reference for the commands so that you don’t have to be connected all the time to use the help module.

Before you go further into finding help for modules, it’s best to update the help command as it may not have all the information in the beginning.

  • Run the PowerShell in the Admin mode and paste the following command to perform the update for the help module:
Update-Help
PowerShell Update-Help
  • You will see the progress bar for updates:
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e0b2dc65-34a7-4ac0-b220-30639265533a/03-updateprogress.png
PowerShell Update-Help Progress

Using Get-Help in PowerShell

You can run the help command on almost every PowerShell command, provided that the third-party modules include the help resources. The most common way to use the help command is by calling Get-Help with the name of the command you wish to look up.

One of the typical commands you may use daily is ls which list your current directory files. Let’s take a look at what the help for the command looks like.

Note: The query for command accepts the wildcard (*) or (?) search, such as Get-Help Get-*, which display the list of all the modules that start with Get-

Run the following command in your terminal to list the help for ls command:

Get-Help ls
PowerShell Get-Help ls Command
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7a0e0ed7-d954-4e4c-890e-2ea23ca8a1d2/04-helpls.png
PowerShell Get-ChildItem Output

The result will display the output for the command, including the following key heading: Name, Synopsis, Syntax, Description, Related Links, and Remarks.

  • Name → Name of the command. In this case, ls is an alias/alternate-name for the Get-ChildItem command in PowerShell.
  • Synopsis → The intent of the command is displayed to give a brief description of what the command does.
  • Syntax →The syntax section covers all the ways you can use the command. If there is more than one use case for any given command, you will see multiple unique syntaxes in this section.
  • Description → The detailed usages and information about the command are available in this section.
  • Related Links → Related links section include any relevant command or modules that might be useful along with the base command you are searching for.
  • Remarks → The final section displays a handful of examples on where else to look for further information on this command. Use this section to get more in-depth information on the modules and commands.

Similarly, you can use a similar search pattern to find the information for almost any command, including the parameters for the specific command in the hierarchy from your PowerShell terminal.

Run the following command in your terminal as an example to get the help for a specific parameter inside the ls module:

Get-Help -Name ls -Parameter Attributes
PowerShell Get-Help with Name and Parameter

Displaying Examples and Verbose Help in PowerShell

Getting the description and syntax is not the only thing you can do with the Get-Help module. PowerShell allows you to pass on some additional help parameters to give you more flexibility on the information you see.

Based on the previous command, you can add -examples flag at the end of the command in your terminal to display examples for the module.

Get-Help ls -example
Get-Help Examples for Get-ChildItem

The output will display the set of examples based on various actions available in the queried command.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a6f1b73d-dc08-42bf-bfcb-afe88cbd63ca/05-helpexample.png
Get-ChildItem Example Output

Similarly, to get the complete set of descriptions, you can use the -full or -detailed flag to display the information. If you wish to read all the detailed information in a browser session at any moment, add -online flag, which will redirect you to the browser on the relevant page for that query.

Conclusion

I hope that gives you an idea of how to query and use the PowerShell Get-Help command to look up examples and details of any command. Consider leveraging the help command wherever you get stuck and need to dig deeper to learn more about the modules.

Check out the previous article in the series of PowerShell:

Stay wired with our newsletter!

Recommended Articles

Stay Up To Date with
Cloud News and Tutorials!

Subscribe to our weekly newsletter!

By entering your email address, you agree to our privacy policy.