In a Unix/Linux environment, you can use the which command to get the location of an executable.
To perform the equivalent task in PowerShell, you can use the Get-Command cmdlet with the following syntax:
(Get-Command notepad).Path
This particular example will return the path where the notepad executable is located on your computer.
If you’d like, you can also shorten this syntax to the following:
(gcm notepad).Path
The following example shows how to use this syntax in practice.
Example: How to Use Equivalent of ‘which’ Command in PowerShell
Suppose that we would like to find the location of the notepad executable on our computer.
We can use the following syntax to do so:
(Get-Command notepad).Path
The following screenshot shows how to use this syntax in practice:

From the output we can see that the notepad executable is located in the following location:
- c:\windows\system32\notepad.exe
Note that we could also use the gcm syntax to get the same result:
(gcm notepad).Path
The following screenshot shows how to use this syntax in practice:

Notice that this returns the same location of the notepad executable.
Feel free to replace notepad with a different name to find the location of a different executable on your computer.
Related Tutorials
The following tutorials explain how to perform other common tasks in PowerShell:
PowerShell: How to Use Group-Object with Multiple Properties
PowerShell: How to Use Sort-Object with Multiple Properties
PowerShell: How to Use Where-Object in List
