Get-Command: List PowerShell Commands
PowerShell has an excellent command-line tool that helps you discover other PowerShell commands. It is called Get-Command
.
In this tutorial, we will learn the PowerShell Get-Command
cmdlet, which we can use to find other commands.
We will start by looking at several practical examples to learn how the Get-Command
cmdlet works.
Examples
List all available Cmdlets, Functions, and Aliases:
Get-Command
Using one of the following commands, you can list all commands that are installed on your computer:
Get-Command *
Get-Command -Type All
List all available cmdlets:
Get-Command -Type Cmdlet
List all functions:
Get-Command -Type Function
Find commands that have the word dns in their name:
Get-Command *dns*
Find commands whose names start with the word restart:
Get-Command restart*
Find commands end with the word computer:
Get-Command *computer
List all commands starting with the verb get:
Get-Command -Verb get
List commands that have the string event in the noun part:
Get-Command -Noun *event*
Find commands of the verb set that has the word firewall in the noun part:
Get-Command -Verb set -Noun *firewall*
List all commands that belong to the NetTCPIP
module:
Get-Command -Module NetTCPIP
Find the commands that use the -ComputerName
parameter:
Get-Command -ParameterName ComputerName
The following command returns the syntax of the Get-Service
cmdlet:
Get-Command Get-Service -Syntax
List only the commands imported to the current session:
Get-Command -ListImported
Get the path to the executable file of the Ping command:
(Get-Command ping).Definition
Run the following command to view the full documentation of the Get-Command
cmdlet:
Get-Help Get-Command -Full
Command Options
The following table lists the most common parameters of Get-Command
cmdlets. You can get the list of all parameters by running the Get-Help Get-Command -Parameter *
command.
-Type, -CommandType | Use this option to Specify the types of commands you want to find (e.g., cmdlets, functions, script, and aliases). |
-ListImported | Displays only the commands imported to the current session. |
-Module | Use this option to find commands in a specific module(s). |
-Verb | Finds the commands that include the specified verb. |
-Noun | Use this option to search a specific word or string in the noun part. |
-ParameterName | Use this option to find commands that use specific parameters. |
-ShowCommandInfo | Displays command information. |
-TotalCount | Use this option to limit the number of results. |
In Windows PowerShell, we use Get-Command
to discover other commands. When you enter Get-Command
without any option, it shows a list of all cmdlets, functions, and aliases:
Get-Command
By default, it includes all cmdlets, functions, and aliases. To list a specific type, use the -Type
parameter. For example, Get-Command -Type Cmdlet
list all cmdlets:
![powershell get command](https://configserverfirewall.s3.us-west-2.amazonaws.com/images/powershell/get-command/get-command.webp)
The following table shows acceptable values for the -Type
parameter.
All |
Alias |
Application |
Cmdlet |
ExternalScript |
Filter |
Function |
Script |
The Get-Command
supports wildcard searches. To search a text anywhere in the command name, put two asterisks (*) at the start and end of the search string.
For example, if the search term is computer, the search will return all commands with the letters "computer" anywhere in the name.
![Find PowerShell commands using get-command.](https://configserverfirewall.s3.us-west-2.amazonaws.com/images/powershell/get-command/find-commands.webp)
To find commands that start with a particular text put an asterisk (*) at the end of the search term.
![find commands that start with a particular text](https://configserverfirewall.s3.us-west-2.amazonaws.com/images/powershell/get-command/find-commands-2.webp)
Start the search term with an asterisk (*) to find commands ending with a particular word or text.
![find commands ending with a particular word or text](https://configserverfirewall.s3.us-west-2.amazonaws.com/images/powershell/get-command/find-commands-3.webp)
All built-in PowerShell commands follow the verb-noun naming format. We can search for a specific text in the verb and noun parts using the -Verb
and -Noun
parameters.
![All built-in PowerShell commands follow the verb-noun naming format](https://configserverfirewall.s3.us-west-2.amazonaws.com/images/powershell/get-command/get-command-verb-noun.webp)
In the following example, we use the -Verb
parameter to find all cmdlets that stop something:
Get-Command -Verb *stop*
This command gets all cmdlets that work with Windows Services:
Get-Command -Noun *service
Use the -ParameterName
to find all commands that use the specific parameter(s). For example following command list all cmdlets that use the -ComputerName
parameter:
Get-Command -Type Cmdlet -ParameterName ComputerName
Another important parameter is the -Module
which you can use to list commands belonging to a specific PowerShell module.
Get-Command -Module NetTCPIP
In the above example, we list all commands belonging to the NetTCPIP
module. You can get a list of all available PowerShell modules by running the Get-Module -ListAvailable
command.
Conclusion
That brings the end of this tutorial about the Get-Command
cmdlet. We learned how to use Get-Command
to list PowerShell Command by looking at several examples.
In the next tutorial, we will learn the Get-Help cmdlet.