Auto Email when StorageGroupCopy Status Failed
Posted March 12th, 2009 by Matt ShadboltMan! I’m killing these powershell scripts today – and they’ve all been related to alerting/reporting via email. If you’ve missed my two other posts – there is a mailbox size report (http://mattlog.net/2009/03/12/auto-email-exchange-2007-mailbox-report/) and a StorageGroupCopyStatus report (http://mattlog.net/2009/03/12/auto-email-exchange-2007-storagegroupcopystatus/)
This one is a little more useful.
Basically, this PowerShell script checks the SummaryCopyStatus and checks that it’s “Healthy” – if not, it will send an email reporting which Storage Group copy has failed. You can run this script every hour or so, and be alerted when any SCR status has gone bad.
This is based on the same email code as my previous two posts. Bare in mind that I’m NOT a developer and my code is more than likely inefficient and ugly!
You can download the script CheckSCRStatus.ps1
Or view the code:
$SCRStatus = Get-StorageGroupCopyStatus -Server PRIMARYSERVER -StandbyMachine SECONDARYSERVER | Where {$_.StorageGroupName -eq “First Storage Group”}
if ($SCRStatus.SummaryCopyStatus -ne “Healthy”)
{
$MessageBody = “The SCR for ” + $SCRStatus.StorageGroupName + ” has failed”
$FromAddress = “FromAddress@yourdomain.com”
$ToAddress = “ToAddress@yourdomain.com”
$MessageSubject = “SCR Status Failure”
$SendingServer = “MAILSERVER”
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $MessageBody
$SMTPMessage.IsBodyHtml = $true
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)
}
Else
{
Write-Host “First Storage Group All Good!”
}
$SCRStatus2 = Get-StorageGroupCopyStatus -Server PRIMARYSERVER -StandbyMachine SECONDARYSERVER | Where {$_.StorageGroupName -eq “Second Storage Group”}
if ($SCRStatus2.SummaryCopyStatus -ne “Healthy”)
{
$MessageBody = “The SCR for ” + $SCRStatus2.StorageGroupName + ” has failed”
$FromAddress = “FromAddress@yourdomain.com”
$ToAddress = “ToAddress@yourdomain.com”
$MessageSubject = “SCR Status Failure”
$SendingServer = “MAILSERVER”
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $MessageBody
$SMTPMessage.IsBodyHtml = $true
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)
}
Else
{
Write-Host “Second Storage Group All Good!”
Exit
}
Tags: Exchange 2007, PowerShell, SCR, StorageGroupCopyStatus
No Responses

Leave a Reply