码迷,mamicode.com
首页 > 其他好文 > 详细

【Exchange server】Get-MailTrafficTopReport

时间:2020-08-03 18:42:13      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:status   tco   and   site   export   write   read   foreach   com   

#在EXO中有Get-MailTrafficTopReport,官网: https://docs.microsoft.com/en-us/powershell/module/exchange/get-mailtraffictopreport?view=exchange-ps 这个report可以很直观的查处一定时间内每个邮箱的发送量,但是在本地Exchange服务器中却没有。

#以下脚本调用了Exchange服务器的get-messagetrackinglog,以及.count()方法,来拿到和EXO get-mailtraffictopreport一样的发送数据

#There is Get-MailTrafficTopReport in EXO, official website: https://docs.microsoft.com/en-us/powershell/module/exchange/get-mailtraffictopreport?view=exchange-ps This report can be intuitively investigated for a certain period of time The sending volume of each mailbox, but not in the local Exchange server.

#The following script calls the get-messagetrackinglog of the Exchange server and the .count() method to get the same sending data as EXO get-mailtraffictopreport


#The below parts needs to be your Exchange server accepted domains
#以下是您本地Exchange服务器上配置的域名
$AcceptedDomains = @("speridian.com","truecoverage.com","sesameindia.com","speridiantec.onmicrosoft.com","finalign.com")
#================================================
#No need to modify the below parts
#以下部分无需更改
$StartDate = Get-Date (Read-Host -Prompt ‘Enter the start date, Eg.  05/01/2020 14:00:00‘)
$StartDate = $StartDate.tostring("MM/dd/yyyy hh:mm:ss")
$endDate =  Get-Date (Read-Host -Prompt ‘Enter the end date, Eg.  05/08/2020 18:00:00‘)
$endDate = $endDate.tostring("MM/dd/yyyy hh:mm:ss")
$CSV = Read-Host "Enter the Export CSV file location (E.g C:\temp)"

$result = @()

$Filter = ""
$i = 0
Foreach($AcceptedDomain in $AcceptedDomains)
{
if($i -eq 0)
{

$Filter = ‘($_.recipientaddress -notlike "*‘ + $AcceptedDomain + ‘*")‘

}else{

$Filter += ‘ -and ($_.recipientaddress -notlike "*‘ + $AcceptedDomain + ‘*")‘

}
$i++
}

$mailoxes = get-mailbox -resultsize unlimited

$Count = 0
Foreach($mailbox in $mailboxes)
{
    $Count++

    $Percent = ($Count/($mailboxes.count)) * 100

    Write-Progress -Activity "Search in Progress" -Status "$Percent% Complete:" -PercentComplete $Percent;

$Tracking = Get-MessageTrackingLog -Start $StartDate -End $EndDate -Sender $mailbox.primarysmtpaddress -resultsize unlimited| where{($filter)}

$result += [PScustomobject]@{
    Sender = $mailbox.primarysmtpaddress
    Count = $tracking.count
    }
}

$result | export-csv ($CSV+"\OutboundMailTrafficReport"+$runDate+".csv") -NoTypeInformation -Encoding utf8

【Exchange server】Get-MailTrafficTopReport

标签:status   tco   and   site   export   write   read   foreach   com   

原文地址:https://blog.51cto.com/12954151/2516143

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!