Find which command PowerShell runs with Get-Command -All

  • Published: 2026.11.15
  • Updated: 2026.11.15
  • Windows

A command can behave differently in two PowerShell windows even when you type the same name. Before reinstalling the program or changing PATH, check what PowerShell resolves that name to. An alias or function can take precedence over an executable you expected to run.

The examples use Git’s git command. Replace the name with the command you are investigating. These commands work in Windows PowerShell 5.1 and PowerShell 7.

See which command is selected

Get-Command -Name git

Read CommandType first. Application identifies an executable, Function identifies a function, and Alias identifies an alias. This tells you whether to investigate an installed program or a name defined in the current session.

If PowerShell reports that the name was not found, check the spelling, installation location, and directories on PATH. A missing result does not, by itself, tell you which of these is responsible.

List commands hidden behind the same name

Get-Command -Name git -All | Select-Object CommandType, Name, Source

-All includes matching commands that are hidden by another command with the same name. In an isolated PowerShell session with a test function named git, the function appeared first and Git executables appeared below it. The executable files still existed, but typing git selected the function.

When you use a name without a path, loaded aliases, functions, cmdlets, and external commands have a defined precedence. An unloaded module is a separate consideration: do not assume that every function in every installed module is already competing with the executable.

Compare executable locations

Get-Command -Name git -CommandType Application -All | Select-Object Name, Source

Filtering to Application lets you compare executable paths without mixing them with functions and aliases. The test environment had two git.exe locations; one was C:\Program Files\Git\cmd\git.exe. Your results depend on what is installed and available on PATH.

Source depends on the command type. For an application it shows the executable path. A function can have an empty Source, so a blank cell does not mean that the function is missing.

Use the result to choose the next check

If a function or alias is selected, look at the profile or module that defines it. If an unexpected executable is selected, compare the reported path with the installation you intended to use. Finding several candidates is a reason to inspect them before changing PATH or removing software.

For SSH, the executable and its configuration directory both matter. See checking which SSH configuration Windows uses when a connection setting appears to be ignored.

Run the lookup in the session where the problem occurs. A name-specific Get-Command lookup can automatically import a matching module, so it should not be described as having no effect on session state.

References