在powershell中扫描特定字符串

时间:2012-07-02 20:37:11

标签: string parsing powershell

我目前正在运行此命令

Get-ChildItem -recurse | Select-String -pattern ('a' OR 'b' OR 'c' OR 'd') | group path | select name | export-csv results.csv

修改它的最佳方法是什么,以便每个输出旁边的csv包含它包含的字符串?

1 个答案:

答案 0 :(得分:2)

$match = @{n='Matches';e={ ($_ | Select-String -Pattern 'a|b|c|d' -AllMatches).Matches | select -expand value | sort -unique}}
Get-ChildItem -Recurse | select name,fullname,$match