Get-ChildItem 'D:\failed log' -Recurse |
Select-String -AllMatches '\w+@\w+\.\w+' |
Select-String -NotMatch '\w+@repoinfotec.\w+'|
Select-Object FileName
Explanantion
以上管道查找除@ repoinfotec.com
问题
它应该找到除@ repoinfotec.com和@ bnymellon.com之外的所有电子邮件地址,那么如何排除2?
我应该将它们放入for循环或类似的东西吗?
答案 0 :(得分:1)
您不需要Get-ChildItem
cmdlet,只需将-Path
传递给Select-String
cmdlet即可。要排除两个域名,请使用正则表达式或|
:
select-string -Path 'your_file' -Pattern '\w+@\w+\.\w+' |
where Line -NotMatch '\w+@(repoinfotec|bnymellon).\w+'