Asked by:
Powershell For SCR Replication Health

Question
-
Hello Everyone -
I have a script that I found from the web and wanted to use it to help send us email notifications on the status of our SCR replication health. We have 8 SCR Storage groups being replicated from 2 different email servers (4 from each server) and I wanted to if someone can help me figure out how to make it so it reads from both servers vs creating the below script 8 times and getting 8 separate emails. The script is below
$SCRStatus = Get-StorageGroupCopyStatus -Server Server1 -StandbyMachine SCRServer | Where {$_.StorageGroupName -eq “SG1”}
if ($SCRStatus.SummaryCopyStatus -eq “Healthy”)
{
$MessageBody = “The SCR for ” + $SCRStatus.StorageGroupName + " is Healthy”
$FromAddress = “Exchange SCR Health <no_reply@Domain.com>”
$ToAddress = “User@Domain.com”
$MessageSubject = “SCR Status”
$SendingServer = “ServerName”
$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
{
$MessageBody = “The SCR for ” + $SCRStatus.StorageGroupName + " has Failed”
$FromAddress = “Exchange SCR Health <no_reply@Domain.com>”
$ToAddress = “User@Domain.com”
$MessageSubject = “SCR Status”
$SendingServer = “ServerName”
$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)
}- Edited by Exchange Nebie Tuesday, September 9, 2014 5:37 PM
- Moved by Bill_Stewart Thursday, September 25, 2014 9:03 PM Move to more appropriate forum
- Moved by Simon_WuMicrosoft contingent staff Monday, September 29, 2014 6:21 AM
Tuesday, September 9, 2014 5:36 PM
All replies
-
Hi,
Just change the server you're pointing at (-Server) and adjust the Where clause as necessary for each iteration. That'll be the quickest fix.
Alternatively you can use ForEach-Object and loop.
Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)
Tuesday, September 9, 2014 5:40 PM -
Hi,
Just change the server you're pointing at (-Server) and adjust the Where clause as necessary for each iteration. That'll be the quickest fix.
Alternatively you can use ForEach-Object and loop.
Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)
Tuesday, September 9, 2014 5:44 PM -
I don't have Exchange 2007 to test with, sorry.
You might get better help asking in the Exchange forums.
Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)
- Proposed as answer by jrv Tuesday, September 9, 2014 7:30 PM
Tuesday, September 9, 2014 5:57 PM -
This is definitely an Exchange group question.
Get-StorageGroup comes to mind:http://technet.microsoft.com/en-us/library/aa998331(v=exchg.80).aspx`
The rest is just basic PowerShell 101.
¯\_(ツ)_/¯
Tuesday, September 9, 2014 7:32 PM