Tuesday 12 March 2019

windows - PowerShell equivalent to the Unix `which` command?


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 , and it tells me. I can't find an equivalent in PowerShell.



Answer



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.



No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...