How to use the command Get-Help (with examples)
- Windows
- December 25, 2023
Get-Help is a command in PowerShell that allows you to display help information and documentation for PowerShell commands, including aliases, cmdlets, and functions. This command is extremely useful for learning about the available functionalities, understanding how to use a specific command, and troubleshooting any issues that may arise.
Use case 1: Display general help information for a specific PowerShell command
Code:
Get-Help command
Motivation: When you come across a PowerShell command that you are unfamiliar with, you can use this use case to quickly obtain general information about the command. This includes the command’s syntax, usage, and brief description.
Explanation: Replace ‘command’ in the code with the actual PowerShell command you want help information for. The command name is case-insensitive.
Example output:
NAME
Get-Process
SYNTAX
Get-Process [[-Name] <String[]>] [-IncludeUserName] [-Module <String[]>] [-FileVersionInfo] [-InputObject <Process[]>] [-VM <SwitchParameter>]...
ALIASES
ps
REMARKS
Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
Use case 2: Display a more detailed documentation for a specific PowerShell command
Code:
Get-Help command -Detailed
Motivation: When you need more detailed documentation for a particular PowerShell command, you can use this use case. The detailed documentation provides more in-depth information about the command, including its parameters, inputs, outputs, and examples.
Explanation: Replace ‘command’ in the code with the actual PowerShell command you want detailed documentation for. The command name is case-insensitive.
Example output:
SYNTAX
Get-Process [[-Name] <String[]>] [-IncludeUserName] [-Module <String[]>] [-FileVersionInfo] [-InputObject <Process[]>] [-VM <SwitchParameter>]...
Get-Process -Id <Int32[]> [-IncludeUserName] [-Module <String[]>] [-FileVersionInfo] [-InputObject <Process[]>] [-VM <SwitchParameter>]...
Get-Process -InputObject <Process[]> [-IncludeUserName] [-Module <String[]>] [-FileVersionInfo] [-Name <String[]>] [-VM <SwitchParameter>]...
...
Use case 3: Display the full technical documentation for a specific PowerShell command
Code:
Get-Help command -Full
Motivation: When you require a comprehensive understanding of a particular PowerShell command, including detailed parameter explanations and usage examples, you can use this use case. The full technical documentation provides extensive information about the command, making it a great resource for advanced users.
Explanation: Replace ‘command’ in the code with the actual PowerShell command you want full technical documentation for. The command name is case-insensitive.
Example output:
SYNTAX
Get-Process [[-Name] <String[]>] [-IncludeUserName] [-Module <String[]>] [-FileVersionInfo] [-InputObject <Process[]>] [-VM <SwitchParameter>]...
...
PARAMETERS
-Name <String[]>
Required? false
Position? 1
Default value None
Accept pipeline input? false
Accept wildcard characters? false
...
INPUTS
None
...
OUTPUTS
System.Diagnostics.Process
...
Use case 4: Print only the documentation for a specific parameter of the PowerShell command (use *
to show all parameters), if available
Code:
Get-Help command -Parameter parameter
Motivation: In many cases, you may only want to extract information about a specific parameter of a PowerShell command. Using this use case, you can print the documentation of the desired parameter, giving you a better understanding of its purpose and how to utilize it.
Explanation: Replace ‘command’ in the code with the actual PowerShell command. Replace ‘parameter’ with the name of the specific parameter you wish to obtain documentation for. If you want to show documentation for all parameters, replace ‘parameter’ with ‘*’.
Example output:
-Name <String[]>
Required? false
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName, ByValue)
Accept wildcard characters? true
...
Use case 5: Print only the examples of the cmdlet, if available
Code:
Get-Help command -Examples
Motivation: Examples are a great way to understand the practical usage of a PowerShell command. By using this use case, you can quickly access a list of examples provided for the specific command, which can assist with your own scripting and automation needs.
Explanation: Replace ‘command’ in the code with the actual PowerShell command you want to see examples for. The command name is case-insensitive.
Example output:
EXAMPLES
Example 1: Get all running processes
PS C:\> Get-Process
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
1021 90 21736 42008 379 47.53 5868 ApplicationFrameHost
567 37 1684 1064 67 25.42 9568 audiodg
782 32 1572 3524 283 85.79 12252 audiodg
...
Use case 6: List all available cmdlet help pages
Code:
Get-Help *
Motivation: If you want to view the help pages for all available cmdlets in PowerShell, this use case is very helpful. By running this command, you can obtain a complete list of cmdlets along with their brief descriptions.
Explanation: The asterisk (*) symbol is used as a wildcard character in this command to match all available cmdlets.
Example output:
Name Category Module Synopsis
---- -------- ------ --------
Get-WmiObject Cmdlet Microsoft.PowerShell.Management Retrieves instances of Windows Management Instr...
Set-WmiInstance Cmdlet Microsoft.PowerShell.Management Modifies the properties of an existing instance...
Use case 7: Update the current help and documentation knowledge base using Update-Help
Code:
Update-Help
Motivation: PowerShell periodically releases updates that include new cmdlets and documentation. By using this use case, you can synchronize your local help and documentation with the latest version available, ensuring that you have access to the most recent features and information.
Explanation: This command doesn’t require any arguments. It automatically detects the installed version of PowerShell and fetches the updated help files accordingly.
Example output:
Preparing to update...
Updating help for module 'PowerShellGet, PackageManagement'.
...
Use case 8: View an online version of PowerShell command documentation in the default web browser
Code:
Get-Help command -Online
Motivation: Sometimes, you may want to access the online version of the PowerShell command documentation to take advantage of additional resources, community discussions, or updated information. By using this use case, you can open the command documentation directly in your default web browser.
Explanation: Replace ‘command’ in the code with the actual PowerShell command. The command name is case-insensitive.
Example output: This command opens the online documentation of the specified PowerShell command in the default web browser.