Equivalent of *Nix 'which' command in PowerShell?

后端 未结 14 2194
刺人心
刺人心 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 00:59

    My proposition for the Which function:

    function which($cmd) { get-command $cmd | % { $_.Path } }
    
    PS C:\> which devcon
    
    C:\local\code\bin\devcon.exe
    

提交回复
热议问题