How to Use Get-Help in PowerShell: Syntax and Examples
Use the
Get-Help cmdlet in PowerShell to get detailed information about commands, their syntax, and examples. Simply type Get-Help CommandName to see help for a specific command.Syntax
The basic syntax of Get-Help is simple and flexible. You use it by typing Get-Help followed by the command name you want help with. You can also add parameters to get more detailed information.
- Get-Help <CommandName>: Shows basic help for the command.
- -Detailed: Shows detailed help including syntax and descriptions.
- -Examples: Shows only examples of how to use the command.
- -Full: Shows the complete help content.
- -Online: Opens the online help page in your browser.
powershell
Get-Help <CommandName> [-Detailed] [-Examples] [-Full] [-Online]
Example
This example shows how to get basic help and examples for the Get-Process command. It demonstrates how to see the command's description and usage examples.
powershell
Get-Help Get-Process Get-Help Get-Process -Examples
Output
NAME
Get-Process
SYNOPSIS
Gets the processes that are running on the local computer or a remote computer.
EXAMPLES
Get-Process
Gets all the processes that are running on the local computer.
Get-Process -Name notepad
Gets the process named notepad.
Common Pitfalls
One common mistake is not updating the help files before using Get-Help, which can cause outdated or incomplete information. Use Update-Help to download the latest help content.
Another pitfall is forgetting to specify the command name, which results in an error or no output.
powershell
Get-Help # This will not work because no command name is specified. Update-Help # Run this once to update help files for accurate information.
Quick Reference
Here is a quick cheat sheet for common Get-Help parameters:
| Parameter | Description |
|---|---|
-Detailed | Shows detailed help including syntax and descriptions. |
-Examples | Shows only usage examples. |
-Full | Shows complete help content. |
-Online | Opens the online help page in a browser. |
-Parameter <name> | Shows help for a specific parameter. |
Key Takeaways
Use
Get-Help CommandName to quickly see help for any PowerShell command.Run
Update-Help regularly to keep help content current and accurate.Add parameters like
-Detailed or -Examples to get more specific help.Always specify the command name with
Get-Help to avoid errors.Use
-Online to view the latest help documentation in your web browser.