Equivalent of *Nix 'which' command in PowerShell?

后端 未结 14 2259
刺人心
刺人心 2020-11-28 00:16

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

14条回答
  •  不知归路
    2020-11-28 01:03

    I usually just type:

    gcm notepad
    

    or

    gcm note*
    

    gcm is the default alias for Get-Command.

    On my system, gcm note* outputs:

    [27] » gcm note*
    
    CommandType     Name                                                     Definition
    -----------     ----                                                     ----------
    Application     notepad.exe                                              C:\WINDOWS\notepad.exe
    Application     notepad.exe                                              C:\WINDOWS\system32\notepad.exe
    Application     Notepad2.exe                                             C:\Utils\Notepad2.exe
    Application     Notepad2.ini                                             C:\Utils\Notepad2.ini
    

    You get the directory and the command that matches what you're looking for.

提交回复
热议问题