统计邮件收发数量
#获取前一天Exchange收发邮件量 $Mail_Servers = "mb11,mb12,mb13,mb14" $Mail_Servers_array = $Mail_Servers -split "," $Count_send = $null $Count_receive = $null $Count_sendout = $null $Count_receiveout = $null $d = ((get-date).adddays(-1)).Date $end_time = $d.AddHours(24) foreach ($Mail_Server in $Mail_Servers_array) { $message_all = Get-MessageTrackingLog -server $Mail_Server -Start $d -end $end_time -ResultSize unlimited #获取发送邮件数量 $sendall_1 = $message_all | ? {$_.EventId -eq "RECEIVE" -and $_.Source -eq "SMTP"} $Count_send += $sendall_1.Count #获取接收邮件数量 $receiveall_1 = $message_all | ? {$_.EventId -eq "DELIVER"} $Count_receive += $receiveall_1.Count #获取发送到外部邮件数量(不含退信) $sendall_external_1 = $message_all | ? {$_.EventId -eq "SENDEXTERNAL" -and $_.Sender -notmatch "postmaster@yx.cn" } $Count_sendout += $sendall_external_1.Count #获取接收的外部邮件数量 $Count_receiveout_1 = $receiveall_1 | ? { $_.sender -notmatch "yx.com" -and $_.sender -notmatch "yx.cn" } $Count_receiveout += $Count_receiveout_1.Count }
参考:https://social.technet.microsoft.com/Forums/zh-CN/7286b683-9396-4d7b-b618-c33b44ece577/message-tracking-log?forum=exchangeserverzhchs