【发布时间】:2019-04-10 23:07:24
【问题描述】:
为什么 powershell 不过滤对象的 toString 方法的输出?
Get-ChildItem cert:\localmachine\my | % { Select-String -InputObject $_.ToString() -Pattern 'testcert' -SimpleMatch }
相反,我只是获得了通常通过跑步获得的一切
Get-ChildItem cert:\localmachine\my | % { $_.ToString() }
我期待像grep 或findstring 这样我会得到与正则表达式匹配的行。
有人会认为,一旦调用$_.ToString(),你只会得到字符串输出……相反,我只是得到对象还是字符串数组?
【问题讨论】:
-
我怀疑 - 在这一点上 - 你不是在看字符串的集合。 [grin] 这意味着您一次只针对一个字符串运行。
标签: powershell windows-10 select-string