在PowerShell中运行时,为什么'where'命令不显示任何输出?
  当我运行where的CMD,我得到的输出: 
C:UsersRagesh> where calc
C:WindowsSystem32calc.exe
但在PS中同样的事情:
PS C:datacode> where calc
PS C:datacode>
输出在哪里?!
以下为我工作:
PS C:UsersBill> where.exe calc
C:WindowsSystem32calc.exe
  当你在PS中键入时where与执行where.exe 
PS C:UsersBill> where  <press ENTER>
cmdlet Where-Object at command pipeline position 1
Supply values for the following parameters:
Property:
  所以,当你键入where calc正在执行Where-Object calc (别名Where-Object是where和? ),因此没有返回,而不是执行where.exe calc 。 
  您可以使用Get-Command (别名gcm )cmdlet代替where.exe 。  下面是一个使Get-Command函数与where.exe完全一样的示例函数。  如果您将其放入PowerShell配置文件中,它将始终在您的会话中可用。 
function which ($command) {
    Get-Command -Name $command -ErrorAction SilentlyContinue | 
        Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}
以下链接可能有用 -
Powershell中命令* Nix'的等价物?
https://superuser.com/questions/34492/powershell-equivalent-to-unix-which-command
希望这可以帮助。
链接地址: http://www.djcxy.com/p/5121.html上一篇: Why doesn't the 'where' command display any output when running in PowerShell?
