Welcome to Matts Admin tips. This blog is full of little fixes, tutorials and work-arounds to those anoying problems that a Systems Administrator might face. If you find something that you have found useful please leave me a comment - I appreciate knowing that I've helped! Also, feel free to leave a comment if my tips or ideas don't work in your environment... I monitor them closely and would be happy to help! Matt

Auto Email when StorageGroupCopy Status Failed

Man! 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: , , ,

No Responses
Filed under:Uncategorized

Leave a Reply