Archive

Archive for the ‘Exchange 2007’ Category

Exchange 2007 spam report script

Een handig script te gebruiken om bijvoorbeeld dagelijks een overzicht te ontvangen van de hoeveelheid spam die is binnengekomen op de Exchange 2007 server. Het script is geschreven in Powershell:

###Send mailbox statistics script

### email
$FromAddress = "report@strengholt-online.nl"
$ToAddress = "piethein@strengholt-online.nl"
$MessageSubject = "Mailbox Size Report"
$MessageBody = "Attached is the current list of mailbox sizes."
$SendingServer = "localhost"

###scripts
Get-MailboxStatistics |where {$_.TotalItemSize -gt 1000MB} | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}} > c:\mailboxes.txt
Get-AntispamTopRecipients.ps1 >> c:\mailboxes.txt
Get-AntispamTopBlockedSenderDomains.ps1 p1 -top10 >> c:\mailboxes.txt
Get-AntispamTopBlockedSenderIPs.ps1 -top 10 >> c:\mailboxes.txt
Get-AntispamTopBlockedSenders.ps1 p1 >> c:\mailboxes.txt

$log = Get-Content c:\mailboxes.txt
$body = New-Object System.Text.StringBuilder
[void] $body.AppendLine("<pre>");
foreach($line in $log)
{
[void] $body.AppendLine($line.ToString())
}
[void] $body.AppendLine("</pre>");

###mail msgs
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress,
$MessageSubject, $body
##$Attachment = New-Object Net.Mail.Attachment("c:\mailboxes.txt")
##$SMTPMessage.Attachments.Add($Attachment)
$SMTPMessage.IsBodyHTML = $true

###senden
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer

$SMTPClient.Send($SMTPMessage)
##$Attachment.dispose()

Categories: Exchange 2007 Tags: