Skip to content

Free PowerShell Script: Monitoring SCR Health

Let me know if you see anything obviously wrong with it. Use at your own risk! :)

#################################
#Copyright 2009 Cohesive Logic LLC
#SCR Health Check Script
#Description – Determines if any of the storage groups on the SCR target server are in an unhealthy state.
#################################

#Options – Specify the following options for the target Enviroment
#################################
#SCR Target Server – Specify the FQDN SCR Target server to be analyzed
$SCRTarget = “Target Server”
#Exchange Mailbox Server – Specify the FQDN for the Exchange Mailbox Server Source for your SCR Target
$MailboxServer = “Source Mailbox Server”
#SMTP Server – Specify FQDN of a local SMTP server that can be used to relay the warning email
$SMTPServer = “SMTP SEERVER NAME by DNS or IP” -
#EmailRecipient – Specify the email address where the warning email shoudl be sent.
$EmailRcpt = “JoeDoe@server.com”
#################################

#The email function used to transmit email over using an SMTP relay
function Send-Email([string]$rcpt,$smtpServer,$body) {

$msg = New-Object net.Mail.MailMessage
$smtp = New-Object net.Mail.SmtpClient($smtpServer)

$msg.From = “ExchangeSCR@Domain.com”
$msg.To.Add($rcpt)
$msg.Subject = “SCR HEALTH WARNING”

$msg.Body = $body
$smtp.Send($msg)
}
#The Check-SCR function determines if replication on any of strorage groups of the SCR target server are in an unhealthy state.
#If any  storage groups are found to be unheathy
function Check-SCR($MBX,$SCR,$SMTP,$rcpt) {
$MessageBody = $NULL
$ReplicatedSG = Get-StorageGroup -Server $MBX | where {$_.StandbyMachines -ne $NULL} | Select Identity
foreach($SG in $ReplicatedSG) {
if((Get-StorageGroupCopyStatus $SG.Identity -StandbyMachine $SCR).SummaryCopyStatus -ne “Healthy”){
$MessageBody += Get-StorageGroupCopyStatus $SG.Identity -StandbyMachine $SCR | Select Identity,SummaryCopyStatus,CopyQueueLength,ReplayQueueLength LastInspectedLogTime,ServiceDown,Failed,Suspend
}
}
if($MessageBody -ne $NULL){
Send-Email $rcpt $SMTP $MessageBody
}
}

Check-SCR $MailboxServer $SCRTarget $SMTPServer $EmailRcpt

Possibly Related Posts:

{ 2 } Comments

  1. gerard | April 14, 2010 at 3:36 pm | Permalink

    for anyone getting errors with this script; typecast the $MessageBody variable as an array:
    $MessageBody = @()

    then pipe $MessageBody output to the formatting commandlets by changing this line of code:
    $MessageBody += Get-StorageGroupCopyStatus $SG.Identity -StandbyMachine $SCR | Select Identity,SummaryCopyStatus,CopyQueueLength,ReplayQueueLength,LastInspectedLogTime,ServiceDown,Failed,Suspend

    to this:
    $MessageBody += Get-StorageGroupCopyStatus $SG.Identity -StandbyMachine $SCR | Select Identity,SummaryCopyStatus,CopyQueueLength,ReplayQueueLength,LastInspectedLogTime,ServiceDown,Failed,Suspend | format-list | out-string

    [Reply]

  2. Winston WOLF | July 8, 2010 at 3:08 am | Permalink

    Thx gerard !!!!!!

    [Reply]

Post a Comment

Your email is never published nor shared. Required fields are marked *
CommentLuv Enabled