PowerShell – Get command path like the “which” command in Linux

I have installed Sublime Text 3 with the Git package but it keeps prompting Git command not found in the PATH variable. Before i update the PATH, i have to figure out where is my Git command.

In Linux, we can get the path of a specific command by which [comamnd].
ex. ~$ which git
powershell-which-1
 

Similarly, we can do it in PowerShell using Get-Command.

  • Get-Command [command] | Select-Object -ExpandProperty Definition

 

This is how i get my Git command.
powershell-which-2

The shorthand for the Get-Command is gcm. So you can do the same as follow.

  • gcm [command] | Select-Object -ExpandProperty Definition

 

Done =)

Reference: StackOverflow – Equivalent of *Nix ‘which’ command in Powershell?

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.