get-command — Show where a command resolves — which / type / command -v across all 5 shells
Equivalents in every shell
command -v jqPOSIX-portable. Prints a path for external commands, the name for builtins/functions/aliases. Exit status non-zero if not found — the canonical `if command -v X` script idiom. `which` (external on most Linuxes, builtin on csh) is the older form but is not POSIX-blessed and behaves differently on Alpine/BusyBox.
whence -p jqZsh `whence` is the rich introspector: `-p` external-only path, `-c` show only the type, `-v` verbose. The POSIX `command -v jq` and the bash `type jq` also work. Zsh prefers a builtin over an external when both exist.
type -p jqFish `type -p` prints the path (no fork); `type -q` is the silent existence check (exit 0 if found, 1 if not). `command -v` works since fish 2.7. Aliases in fish are functions, so `type jq` shows function bodies for aliased commands.
Get-Command jqAliased as `gcm`. Returns a `[CommandInfo]` object — `.Source` is the resolved path, `.CommandType` is Alias / Function / Cmdlet / Application / ExternalScript, `.Parameters` is the parameter dictionary. Errors loudly when missing — pair with `-ErrorAction SilentlyContinue` in existence-check scripts.
where jqBuilt-in `where`. Prints every matching PATH entry (`/F` quotes the path; `/Q` quiet mode for existence checks). Errors if not found. cmd has no equivalent to `command -v` for builtins — `where cd` errors because `cd` is internal.
Worked examples
Resolve a command to its path
command -v ffmpegtype -p ffmpeg(Get-Command ffmpeg).Sourcewhere ffmpegScript-friendly existence check
command -v jq >/dev/null && echo foundif (Get-Command jq -ErrorAction SilentlyContinue) { "found" }where /Q jq && echo foundList every kind of binding for a name
type -a pythonGet-Command python -AllGotchas
- `Get-Command <name>` THROWS a non-terminating error (red text on stderr) by default when the command is missing — corrupts otherwise-silent script output. Always pair with `-ErrorAction SilentlyContinue` for existence checks, or wrap in a `try { Get-Command X } catch { $false }`.
- `-All` returns every binding in PRECEDENCE order — alias first, then function, then cmdlet, then external. The default (no `-All`) returns only the FIRST match. If `python` is both a function and an external binary, plain `Get-Command python` shows only the function.
- `(Get-Command X).Source` is the resolved path for `Application` / `ExternalScript` types. For `Cmdlet` it's the module path; for `Function` and `Alias` it's empty. Scripts that blindly index `.Source` get `$null` on builtins — guard with a `.CommandType` check first.
- Wildcards: `Get-Command Get-*` lists every cmdlet whose name starts with `Get-`. Combined with `-Module` you can filter to a specific module, useful for discovery. Bash users miss this — `command -v Get-*` does NOT pattern-match.
- On Linux/macOS pwsh, `Get-Command` resolves through PowerShell's own command table FIRST, then `$PATH`. If a function or alias shadows an external (e.g. `function ls { ... }` in `$PROFILE`), `Get-Command ls` returns the function, not `/bin/ls`. Use `Get-Command -CommandType Application ls` to bypass.