随笔 - 911  文章 - 5  评论 - 94  阅读 - 243万

统计邮件收发数量

 

复制代码
#获取前一天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

 

posted on   momingliu11  阅读(147)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2021-09-22 Docker安装Kibana
2015-09-22 Hyper-V迁移---委派
2014-09-22 添加MIME类型
2014-09-22 IIS功能查看、配置
2014-09-22 IIS下的身份验证方式管理
2014-09-22 PowerShell管理IIS(新建站点、应用程序池、应用程序、虚拟目录等)
2014-09-22 虚拟目录和应用程序的区别
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示