我正在尝试弄清楚如何跟踪逐个发送的电子邮件,而无需抄送任何组或仅限单个收件人的用户。
我有这个脚本,但显示所有电子邮件,包括抄送,我遗漏了什么吗?
$senders=Get-User -Organization xx | Where { $_.RecipientType -eq ‘UserMailbox’ -and $_.useraccountcontrol -notlike '*accountdisabled*'}
Foreach($sender in $senders)
{
Get-MessageTrackingLog -Start (Get-Date).AddHours(-3) -ResultSize Unlimited -Sender $sender.WindowsEmailAddress |?{$_.RecipientStatus -notcontains "cc" -and $_.RecipientCount -eq '1' -and $_.sender -notlike '[email protected]' -and $_.Recipients -notlike "*@domain.com" } | select Sender,@{N="Receiver";E={$_.Recipients}},RecipientCount,Messagesubject,TimeStamp
}
答案1
您RecipientStatus
想要过滤的 仅似乎包含在 中RECEIVE
EventId
。
? {$_.EventId -eq "RECEIVE" -and $_.RecipientStatus -notcontains "cc" [... more code ...]