0

How do I check where an executable of a program is located using PowerShell?

In the bash shell it'd be (e.g. for Python):

$ which python
/c/Users/user/.pyenv/pyenv-win/shims/python
Andreas L.
  • 3,239
  • 5
  • 26
  • 65
  • https://stackoverflow.com/questions/63805/equivalent-of-nix-which-command-in-powershell?r=SearchResults – Daniel Jun 02 '21 at 07:39
  • Thanks @Daniel for the additional resources. – Andreas L. Jun 02 '21 at 07:43
  • Does this answer your question? [Equivalent of \*Nix 'which' command in PowerShell?](https://stackoverflow.com/questions/63805/equivalent-of-nix-which-command-in-powershell) – jonrsharpe Jun 02 '21 at 07:56
  • That's the same link @Daniel posted already. Several answers and rationales are provided, but I like the conciseness of Martin's answer below. Nothing else is needed for my scope, it just works. – Andreas L. Jun 02 '21 at 07:58
  • Yes, it is, but they hadn't actually voted for duplicate closure. The `gcm` answers is also on the dupe: https://stackoverflow.com/a/63891/3001761. You might not need the other options, but the point of this process is for the _next person_ who finds this who might. – jonrsharpe Jun 02 '21 at 15:21
  • I agree. The only thing that got me was the naming of that duplicate question, wherefore I couldn't find it myself. While it might be more accurate to say `*NIX` it might not be obvious for everyone, especially for those not being experts in the field. If I can't find a question with various search trials, I file my own and then of course one can link to the other one which is more popular. Yet, I feel stackoverflow should allow for more search criteria linking questions to other keywords, even though these might not be mentioned directly in the OP. – Andreas L. Jun 04 '21 at 09:59

1 Answers1

2

I use the Get-Command cmdlet (short gcm) for that:

gcm python
Martin Brandl
  • 56,134
  • 13
  • 133
  • 172