PowerShell Get-Command
The PowerShell Get-Command cmdlet is used to get all the commands which are installed on the computer system. This cmdlet includes functions, other cmdlets, aliases, filters, scripts, and applications. We can get only those commands which have been imported into the current session by using the -ListImported parameter.
With the starting of Windows PowerShell 5.0, this cmdlet displays a version column by default.
Syntax
Parameters
-ArgumentList
The -ArgumentList parameter is used to specify an array of arguments. An alias for this parameter is Args. Wildcard characters are not supported.
-Verb
The -Verb parameter is used to specify an array of command verbs. Wildcard characters are accepted.
-Noun
The -Noun parameter is used to specify an array of command nouns. Wildcard characters are accepted.
-Module
The -Module parameter is used to specify an array of modules. It gets those commands which come from the specified modules.
The -Module parameter takes the string values, but the value of it can also be a PSModuleInfo object.
-FullyQualifiedModule
The -FullyQualifiedModule parameter is used to specify the modules with names which are specified in the form of ModuleSpecification objects.
-TotalCount
The -TotalCount parameter is used to specify the number of commands to get. We can also use it to limit the output of the command.
-Syntax
The -Syntax parameter is used to indicate that this cmdlet gets the following specified data about the command:
- Functions and filters: Gets the definition of a function.
- Aliases: Gets the name of a standard.
- Cmdlets: Gets the syntax.
- Scripts and applications or files: Gets the filename and path.
-ShowCommandInfo
The -ShowCommandInfo parameter is used to indicate that this cmdlet shows only the information of a command. It was introduced in Windows PowerShell 5.0.
-All
It is used in this cmdlet to get all those commands, which include commands of the same type that have the same name. It was introduced in Windows PowerShell 3.0.
-ListImported
The -ListImported parameter is used in this cmdlet to get only the commands in the current session. It was introduced in Windows PowerShell 3.0.
-Name
The -Name parameter is used to specify an array of names. It is used in this cmdlet to get only those commands that have a specified name. Wildcard characters are accepted.
-CommandType
The -CommandType parameter is used to specify the type of command that this cmdlet returns. We can also use Type as its alias.
-ParameterName
The -ParameterName is a parameter which is used to specify the parameter names. This cmdlet gets those commands in the session which have the specified parameter. Wildcard characters are accepted. It was introduced in Windows PowerShell 3.0.
-ParameterType
The -ParameterType is a parameter which is used to specify the array of parameter types. This cmdlet gets those commands in the session, which have the parameters of a specified type. Enter the full or partial name of the parameter type. The characters of wildcard are permitted. It was introduced in Windows PowerShell 3.0.
Examples
Example 1: Get all the cmdlets, aliases and functions
This cmdlet displays all the cmdlets, aliases, and functions on the PowerShell console, which are installed on the computer.
Example 2: Get commands in the current session
The cmdlet in this example uses the -ListImported parameter to get the commands in the current session.
Example 3: Get commands in a Module
The cmdlet in this example uses the -Module parameter to get the commands in Microsoft.PowerShell.Utility and Microsoft.PowerShell.Security modules.
Example 4: Get the syntax of any cmdlet
The cmdlet, in this example, uses the -ArgumentList and -Syntax parameters to get the syntax of Get-childItem cmdlet.
Example 5: Get the commands of all types
The cmdlet, in this example, displays all the commands of all types on a local computer.
Example 6: Get a module name that contains a cmdlet
The cmdlet in this example displays the name of a module in which the Get-Item cmdlet originated.