Why doesn't the 'where' command display any output when running in PowerShell?
当我在CMD中运行
1 2 3 | C:\Users agesh> where calc C:\Windows\System32\calc.exe |
但在PS中同样的事情:
1 2 | PS C:\data\code> where calc PS C:\data\code> |
输出在哪里?!
以下对我有用:
1 2 | PS C:\Users\Bill> where.exe calc C:\Windows\System32\calc.exe |
在PS中键入
1 2 3 4 5 | PS C:\Users\Bill> where [cc lang="powershell"] cmdlet Where-Object at command pipeline position 1 Supply values for the following parameters: Property: |
因此,当您键入
您可以使用
1 2 3 4 | function which ($command) { Get-Command -Name $command -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue } |
以下链接可能有用 -
相当于* Nix''在Powershell中的命令?
https://superuser.com/questions/34492/powershell-equivalent-to-unix-which-command
希望这可以帮助。