使用此脚本可以检查SCR的状态和邮件结果。
$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 = [email=“
FromAddress@yourdomain.com]“
FromAddress@yourdomain.com[/email]”
$ToAddress = [email=“
ToAddress@yourdomain.com]“
ToAddress@yourdomain.com[/email]”
$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 = [email=“
FromAddress@yourdomain.com]“
FromAddress@yourdomain.com[/email]”
$ToAddress = [email=“
ToAddress@yourdomain.com]“
ToAddress@yourdomain.com[/email]”
$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
}