Go to index

Get-Command

Reference

Listing/Finding the commands using Get-Command

List all the commands

To list all the cmdlets, functions and aliases available in the current session and imported from the remote sessions as well.

Get-Command

To list applications and external scripts along with the cmdlets, functions and aliases.

Get-Command *

To list all the commands from current session only

Get-Command -ListImported

To limit the output count

Get-Command -TotalCount 10

List the commands in a module

To list all the commands in the module Microsoft.PowerShell.Core

Get-Command -Module Microsoft.PowerShell.Core

List the commands with a specific type

To list all the commands of a specific type (CmdLet/Function/Alias/ExternalScript/Application)

Get-Command -CommandType CmdLet

To list all the applications (executable files) available the paths of PATH environment variable

Get-Command -CommandType Application

Command with a specific name

Gets the command by its name

Get-Command -Name Get-ComputerInfo

Gets the commands by name matching with the given wildcard pattern

Get-Command -Name *ipaddress*

Commands with a specific verb or noun

To list the commands with a specific verb

Get-Command -Verb Invoke

To list the commands with a specific noun

Get-Command -Noun Computer

To list the command with a specific verb and noun combination

Get-Command -Verb Get -Noun Host

To list the commands with a specific verb matching with the wildcard

# Gets both Get and Set commands
Get-Command -Verb *et

To list the commands with a specific noun matching with the wildcard

Get-Command -Noun *Info

To list the command with a specific verb and noun combination using the wildcard pattern

Get-Command -Verb *et -Noun Host

You can’t use -Name with -Verb or -Noun or with both

Get an alias with a specific name

Get-Command dir

List the commands with parameter attributes

Get the commands by either the parameter name or parameter type, or both.

Get-Command -ParameterName VMName
Get-Command -ParameterType System.Boolean
Get-Command -ParameterName Scoped -ParameterType System.Boolean

Search the commands from closest match to least likely match.

You can use this switch if you are not sure about exact name of the command, and you can’t use this with wildcard search, and works only with -Name parameter combination

Get-Command -Name gotcemmand -UseFuzzyMatching

List the commands with the same name from different sources

To test this, create an empty Write-Error function and then run the command below

To create an empty function: Function Write-Error {}

Get-Command -Name Write-Error -All

# or
Get-Command -Name notepad -All

List the commands using the FullyQualifiedModule parameter

To list the commands from the specific version of the module

Get-Command -FullyQualifiedModule @{ModuleName = "UEV"; ModuleVersion = "2.1.639.0" }

Get the commands count

Gets the commands count

Get-Command | Measure-Object -Line | Select-Object -ExpandProperty Lines
Get-Command -ListImported | Measure-Object -Line | Select-Object -ExpandProperty Lines

List commands return output, and its type

List all the commands which return output and its output type

Get-Command | Where-Object OutputType | Format-List

Get information about a specific CmdLet using Get-Command

Get the syntax(s) of a given command

To refer the syntax of a command

Get-Command -Name Get-Counter -Syntax

Get complete information about the given command

To list all the information related to the given command

Get-Command -Name New-NetIPAddress | Format-List *

Get all the parameters of a given command

Gets the list of parameters

Get-Command -Name Get-ControlPanelItem | Select-Object -ExpandProperty Parameters
# Or
(Get-Command -Name Get-ControlPanelItem).Parameters

Get the module name of a given command

Gets the module/source name of a given command

Get-Command -Name Show-ControlPanelItem | Select-Object -ExpandProperty ModuleName
# Or
(Get-Command -Name Show-ControlPanelItem).ModuleName

Get the definition of a given command

Gets the function code

Get-Command -Name Get-NetAdapterStatistics | Select-Object -ExpandProperty Definition
# Or
(Get-Command -Name Get-NetAdapterStatistics).Definition

Get the command output type

Gets the command output type

Get-Command -Name Get-NetAdapterHardwareInfo | Select-Object -ExpandProperty OutputType
# Or
(Get-Command -Name Get-NetAdapterHardwareInfo).OutputType

Get the command’s default parameter set

To know the default parameterset

Get-Command -Name Get-Disk | Select-Object -ExpandProperty DefaultParameterSet
# Or
(Get-Command -Name Get-Disk).DefaultParameterSet

Get the command type of a given command

To know the type of a given command

Get-Command -Name Get-NetRoute | Select-Object -ExpandProperty CommandType
# Or
(Get-Command -Name Get-NetRoute).CommandType

Get the dynamic parameter list of a given command (if any)

List all the dynamic parameters of a given command

Get-Command -Name Get-Package -ArgumentList 'Cert:' | `
Select-Object -ExpandProperty ParameterSets | `
ForEach-Object {$_.Parameters} | `
Where-Object {$_.IsDynamic} | `
Select-Object -Property Name -Unique


Go to index
Last modified: 2 October 2020