This works in command prompt:
where Java
In PowerShell where
is an alias for Where-Object
. I tried to stop parsing:
--% where Java
This does not work, also tried storing as a variable:
$StopParser = "--%"
$StopParser where Java
This returns the error: 'Unexpected token 'where' in expression or statement'.
How can I use the where command in PowerShell?
This isn't a question of parsing, but of command origins. The where
cmd command is an executable in System32 that searches your current directory and the PATH environment variable for a pattern:
WHERE Java
is equivalent to:
cmd.exe /C where.exe Java
The link I provided shows an equivalent command for powershell
:
(Get-Command -Name $file).Definition
or you can alternatively call the executable the same way:
where.exe Java
For quite a few cmd tools, this is the same paradigm: an executable in System32.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.