Locate an executable with PowerShell

Publish Date: April 23, 2024

Locate an executable with PowerShell

Did you ever need to find the path of an executable in Windows? For instance, you run adb.exe command and it magically works but you don’t know where the executable is actually located on your Windows system. In a traditional command prompt (i.e., cmd.exe), you can simply run the where <executable_name> command and it will show you the complete path, as shown in the screenshot below:

Locate an executable in command prompt

Well, this command works because you have added executable’s path to the PATH environment variable. But you cannot do the same thing in PowerShell. This is because PowerShell has a built-in alias of where for the Where-Object cmdlet. So, if you run the same command in PowerShell, you will get nothing.

To locate an executable’s path in PowerShell, you can use any of the following commands:

(get-command adb).source
(get-command adb).path
(gcm adb).path

Locate an executable in powershell

Remember that gcm is just an alias of the Get-Command cmdlet. By the way, if you’re on a Linux computer, you can locate an executable by running the which <executable_name> command, as shown in the screenshot below.

Locate an executable on Linux

That was all for this post. You just learned how to find an executable’s path on your computer.

Microsoft Certified | Cisco Certified

Leave a Reply