运行 在 cmd 提示符下使用管道的 PowerShell cmd

running PowerShell cmd with pipeline in cmd prompt

我想运行 cmd select-string 在cmd 提示符下递归查找一些字符串。

但是当 cmd 有管道符(|) 字符时它不能工作,它会通过 运行在 powershell 提示符下运行 cmd 来工作。

中文错误信息为:

'select-string' is not recognized as an internal or external command,
operable program or batch file.

谁能知道如何解决这个问题? 在 cmd 提示符中使管道有意义或使用 select-string 查找字符串递归。

我想让它适用于我的情况,非常感谢。

根据建议,您需要在 PowerShell 中使用管道,而不是在 cmd 中。你可以这样做:

powershell "Get-ChildItem | Select-String -Pattern 'something something'"

注意:当然这只是一种变通方法,我仍然建议只在 PowerShell 中使用 运行 PowerShell cmdlet,而不是在 cmd 中。它可以让您免于对无法运行的代码进行故障排除的麻烦。