本文介绍了用于SCR复制健康的Powershell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone -  

Hello Everyone - 

我有一个我在网上找到的脚本,希望用它来帮助向我们发送有关SCR复制状态的电子邮件通知健康。我们从2个不同的电子邮件服务器(每个服务器4个)复制了8个SCR存储组,如果有人可以帮我弄清楚如何制作它,以便从两个服务器读取而不是创建以下脚本,我想要
时间和收到8个单独的电子邮件。该脚本位于

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 |  其中{$ _。StorageGroupName -eq"SG1"} 

if($ SCRStatus.SummaryCopyStatus -eq"Healthy") 



$ MessageBody ="SCR为"+ $ SCRStatus.StorageGroupName +"是健康的" 

$ FromAddress ="Exchange SCR健康< [email protected]>" 

$ ToAddress ="[email protected]"  ; $
$ MessageSubject ="SCR状态" 

$ SendingServer ="ServerName" 

$ SMTPMessage =新对象系统。 Net.Mail.MailMessage $ FromAddress,$ ToAddress,$ MessageSubject,$ MessageBody 

$ SMTPMessage.IsBodyHtml = $ true 

$ SMTPClient = New-Object System.Net .Mail.SMTPClient $ SendingServer 

$ SMTPClient.Send($ SMTPMessage) 



Else 



$ MessageBody ="SCR为"+ $ SCRStatus.StorageGroupName +"已失败" 

$ FromAddress ="Exchange SCR健康状况< [email protected]>" 

$ ToAddress ="[email protected]"  ; $
$ MessageSubject ="SCR状态" 

$ SendingServer ="ServerName" 

$ SMTPMessage =新对象系统。 Net.Mail.MailMessage $ FromAddress,$ ToAddress,$ MessageSubject,$ MessageBody 

$ SMTPMessage.IsBodyHtml = $ true 

$ SMTPClient = New-Object System.Net .Mail.SMTPClient $ SendingServer 

$ SMTPClient.Send($ SMTPMessage) 

$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 <[email protected]>" 
$ToAddress = "[email protected]
$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 <[email protected]>" 
$ToAddress = "[email protected]
$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) 

推荐答案

只需更改您指向的服务器(-Server)并将Where子句调整为每次迭代都需要。这将是最快的解决方案。

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.

或者你可以使用ForEach-Object和循环。

Alternatively you can use ForEach-Object and loop.


这篇关于用于SCR复制健康的Powershell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 01:16