Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

There are a number of times I'd like to know the location of something I'm running from the command line. In unix I just do which <command> and it tells me. I can't find an equivalent in Powershell.

share|improve this question
add comment

3 Answers

up vote 16 down vote accepted

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 is to ensure it will start as a new line.
share|improve this answer
    
Exactly what I was looking for. thanks! –  Herms Sep 2 '09 at 19:17
add comment
function which([string]$cmd) {gcm -ErrorAction "SilentlyContinue" $cmd | ft Definition}
share|improve this answer
add comment

Also answered in 2008: Is there an equivalent of 'which' on windows?

Try the where command if you've installed a Resource Kit: http://ss64.com/nt/where.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.