多个通配符/域到一个csv的邮件跟踪日志

时间:2018-10-31 13:40:12

标签: powershell csv microsoft-exchange

我需要创建一个脚本来提取两个域的邮件跟踪日志, @domain1.com@domain2.com,通过sendindg消息来显示哪些用户或外部电子邮件地址到达了两个域之一。 该报告应插入(两个通配符的)csv中。

使用以下命令,我能够使脚本在一个域中工作。

Get-TransportServer | 
    Get-MessageTrackingLog -ResultSize Unlimited -Start((get-date).AddDays(-1)) -End(get-date) | 
    where {$_.recipients -like "*domain1.com*"} | 
    select sender, {$_.Recipients}, timestamp | 
    export-csv -delimiter "," -path C:\andcombined.csv -notype

现在我需要为此添加第二个域... 我几乎没有尝试添加第二个域,但是它不起作用,请参见下文。

Get-TransportServer | 
    Get-MessageTrackingLog -ResultSize Unlimited -Start((get-date).AddDays(-1)) -End(get-date) | 
    where {$_.recipients -like "*domain1.com*" -and $_.recipients -like "*domain2.com*" | 
    select sender, {$_.Recipients}, timestamp | 
    export-csv -delimiter "," -path C:\andcombined.csv -notype

非常感谢您对此主题的任何帮助。 谢谢大家。

最好的问候

1 个答案:

答案 0 :(得分:1)

-and将匹配两个域中的项目。我只能假设它为零。

将where子句更改为此:

where {$_.recipients -like "*domain1.com*" -or $_.recipients -like "*domain2.com*"}