Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of *Nix 'which' command in PowerShell?

How do I ask PowerShell where something is?

For instance, "which notepad" and it returns the directory where the notepad.exe is run from according to the current paths.

like image 956
DevelopingChris Avatar asked Sep 15 '08 15:09

DevelopingChris


People also ask

Which is an equivalent PowerShell command?

Use Get-Command as the Equivalent of Which Command in PowerShell. The Get-Command cmdlet displays all commands installed on the computer, including cmdlets , aliases , functions , filters , scripts , and applications .

What means $_ in PowerShell?

$_ in the PowerShell is the 'THIS' toke. It refers to the current item in the pipeline. It can be considered as the alias for the automatic variable $PSItem.

What is the equivalent of && in PowerShell?

The & operator in PowerShell is just the ; or Semicolon. The && operator in PowerShell has to be run as an if statement.


1 Answers

The very first alias I made once I started customizing my profile in PowerShell was 'which'.

New-Alias which get-command 

To add this to your profile, type this:

"`nNew-Alias which get-command" | add-content $profile 

The `n at the start of the last line is to ensure it will start as a new line.

like image 83
halr9000 Avatar answered Oct 02 '22 13:10

halr9000