Search notes:

PowerShell: command

A PowerShell command is one of the following:

Precedence

When entering a command in a PowerShell session, the following order of precedence is applied to resolve the command if multiple commands have the same name:
An example of an ambigous command on Windows, PowerShell 5.1, is sc which can refer either to the executable sc.exe or the alias for set-content) (Apparently, in PowerShell 7, sc is not pre-defined as alias anymore):
get-command sc -all

CommandType     Name                Version    Source
-----------     ----                -------    ------
Alias           sc -> Set-Content
Application     sc.exe              10.0.19... C:\WINDOWS\system32\sc.exe
In order to make sure that a specific command type is executed, the PowerShell: call operator (&)[call operator (&) might be used on an object that is returned by get-command … -commandType …:
& (get-command sc -commandType application) query
If a command cannot be resolved, PowerShell also tries to resolve it by prepending it with get-. For example: entering job executes get-job.

See also

Using the Command line parameter -command (or -c)], PowerShell can be started to execute one command and then exit.
Commands that are entered on the prompt (CLI) are stored in the command history
The cmdLet noun command.
The value of a variable can be evaluated as a command with the invoke-expression cmdLet.
The automatic variable myInvocation stores information about the current command if the command is a script, a function or a script block.
The .NET class System.Management.Automation.CommandInfo.
Coloring the output of a command.
The time it takes to finish a command can be measued with the measure-command cmdlet
The status of the last executed command is stored in the automatic variable $?

Index