如何在PowerShell命令行中使用findstr中的双引号字符?

这个命令行在cmd.exe中运行:

findstr /l /i /s /c:"key=\"Smtp" *.config 

然而,在Windows 7 Ultimate x64上运行PowerShell 2时,无论使用哪种组合,findstr似乎都会冻结。 我正在search一个我创build的玩具文件(只有一个文件夹)只有这个入口,所以我知道这不仅仅是花费更长的时间:

 <add key="SmtpHost" value="localhost"> 

但是我尝试过的这些变体在PowerShell中永远不会返回(它们也不会提供>>提示符来指示未终止的string)。

 findstr /l /i /s /c:"key=`"Smtp" *.config findstr /l /i /s /c:"`"" *.config findstr /l /i /s /c:"key=""Smtp" *.config findstr /l /i /s /c:'key="Smtp' *.config 

当我改变它使用正则expression式,与通配符,它​​将工作:

 findstr /r /i /s /c:"key=.Smtp" *.config 

但是如何在PowerShell中成功将双引号传递给findstr呢?

尝试这个:

findstr / l / i / s / c:“key = \”“Smtp”* .config

你需要摆脱豪华和\ “`

更多信息在这里: http : //www.rlmueller.net/PowerShellEscape.htm

是否有一些function,你从Findstr得到,你不能从Powershell cmdlet本身?

 Get-ChildItem .\* -Include *.config -Recurse | Select-String '"key="Smtp"'