Home » Questions » Computers [ Ask a new question ]

PowerShell equivalent to the Unix `which` command?

PowerShell equivalent to the Unix `which` command?

Does PowerShell have an equivalent to the which command found in most (if not all) Unix shells?

Asked by: Guest | Views: 209
Total answers/comments: 2
Guest [Entry]

"This was asked and answered on Stack Overflow: Equivalent of *Nix 'which' command in PowerShell?

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."
Guest [Entry]

"Also answered in 2008: Is there an equivalent of 'which' on the Windows command line?

Try the where command if you've installed a Resource Kit.

Most important parts of the answer:

Windows Server 2003 and later provide the WHERE command which does
some of what which does, though it matches all types of files, not
just executable commands.

[snip]

In Windows PowerShell you must type where.exe."