RSS

exchange 报表系列之邮件流查询01

16 May

适用于:exchange2007, 不确认exchange2010的兼容情况。

目标: 获取一段时间内某一OU下账户的邮件发送情况

现状:ou下账户的SMTP为displayname+OUname.

设计:使用import-csv导入ou名,然后根据ou名来进行发信人的查询

缺点:如果ou下存在SMTP不为displayname+OUname类型的账户,则该账户的信息不会被统计。

进一步的更新: 暂无。

需搭配的文件: 1.csv,放置在脚本同目录下,第一行为OUname,第二行开始为实际ou的名字。(OU名需要为域内唯一)

脚本:

---start---
$a = Get-ExchangeServer bj-hub* | Get-MessageTrackingLog -Start 2010-4-13
-end 2010-5-13 -ResultSize unlimited -eventid receive
$Report = @()
$allou = import-csv -path 1.csv
foreach ($a3 in $allou){
$aaaa= '*' + ($a3.ouname).tostring() + '@company.com*'
$aaaa
$aaaa1= ($a3.ouname).tostring()
$ouinfor = $a | ? {$_.sender -like $aaaa}
if ($ouinfor -ne $null) {
$ouinfor | % {$b=0 }{ $b = $b+ $_.totalbytes } {$b = ("{0:N2}" -f ($b/1mb)) +
"MB" }
$c = $ouinfor.count
$d = ($ouinfor | group sender).count
}
else {$b=$c=$d=0}
$suboureport = New-Object System.Object
Add-Member -InputObject $suboureport -MemberType Noteproperty -Name "OU Name"
-Value $aaaa1
Add-Member -InputObject $suboureport -MemberType Noteproperty -Name "Mail
Count"
-Value $c
Add-Member -InputObject $suboureport -MemberType Noteproperty -Name "Sender
Count"
-Value $d
Add-Member -InputObject $suboureport -MemberType Noteproperty -Name "Sent
Mail Total Size"
-Value $b
$report += $suboureport
}
$report | export-csv messagereport.csv
---end---

报表展示:

Advertisements
 
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: