给脚本给exchange 2010用户发出邮件配额警告邮件


All what’s inside * * should be edited

If ((Get-PSSnapin | where {$_.Name -match “Exchange.Management”}) -eq $null)
 {
 Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
 }
 $toArray=Get-Mailboxdatabase *databasename* | Get-Mailbox | foreach-object {$email = $_.primarysmtpaddress; $_ | Get-MailboxStatistics | Where {$_.TotalItemSize.Value.ToMB() -gt 512 } | select @{ expression={$email}}}
 $from= “*Administartor@domain.com*”
Foreach ($to in $toArray)
 {
 $s=[string]$to
 [int]$Start = $s.IndexOf(“=”)
 [int]$End = $s.IndexOf(“}”)
 [string]$ss=$s.Substring($Start+1,$End-$start-1)
 $Statistics = Get-MailboxStatistics $ss
 $name = Get-Mailbox $ss
 $messageParameters = @{
 smtpServer = “*ExchangeCASHUBserver*”
From = [string]$from
 To = $ss
 Subject = “Warning!”
Body = “Hi “+ $name + “.Your mailbox size is ” + $Statistics.TotalItemSize + ” Your mailbox size limit is 500 MB. Please delete unnecessary emails to reduce size of your mailbox ”
}
Send-MailMessage @messageParameters -BodyAsHtml
 }

参考:http://msexchangeguru.com/2012/08/21/quota-warning/

历史评论

暂无保留的历史评论。

评论为旧站历史记录,本站不再接受新评论。