Why doesn't the 'where' command display any output when running in PowerShell?
 When I run where in CMD, I get output:  
C:UsersRagesh> where calc
C:WindowsSystem32calc.exe
But the same thing in PS:
PS C:datacode> where calc
PS C:datacode>
Where's the output going?!
The following worked for me:
PS C:UsersBill> where.exe calc
C:WindowsSystem32calc.exe
 When you type where in PS, it is not same as executing where.exe  
PS C:UsersBill> where  <press ENTER>
cmdlet Where-Object at command pipeline position 1
Supply values for the following parameters:
Property:
 So when you type where calc it is executing Where-Object calc (the alias of Where-Object is where and ? ) and thus returns nothing, and not executing where.exe calc .  
 You can use the Get-Command (alias gcm ) cmdlet instead of where.exe .  Here is an example function to make Get-Command function exactly like where.exe .  If you put this in your PowerShell profile it will always be available in your session.  
function which ($command) {
    Get-Command -Name $command -ErrorAction SilentlyContinue | 
        Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}
The following links may be useful -
Equivalent of *Nix 'which' command in Powershell?
https://superuser.com/questions/34492/powershell-equivalent-to-unix-which-command
Hope this helps.
链接地址: http://www.djcxy.com/p/5122.html上一篇: 如何将命令行参数传递给批处理文件?
