I just noticed that this script will notify in the event of DAG failover, but is there a way to notify me every 30 mins that all DBs are indeed running on their correct (activation preference 1) servers? This is more of what I am looking for.
From: [email protected] [mailto:[email protected]] On Behalf Of Mazzaccaro, David Sent: Friday, December 11, 2015 10:29 AM To: [email protected] Subject: [Exchange] How to get notification of DAG failover? Hi all, What are others using for a reliable, immediate notification that an Exchange (2010) database has failed over to another server? I found the below script, which looks perfect. I am thinking of setting it as a scheduled task for every 30 min... But I just wanted to check if anyone had any other/better/different methods. Thx! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # MonitorDAG.ps1 # Script to monitor DAG in Exchange 2010 # # Nuno Mota # Team @MSExchangeGuru Function sendEmail ([String] $body) { $MailMessage = New-Object System.Net.Mail.MailMessage $MailMessage.From = "[email protected]<mailto:[email protected]>" $MailMessage.To.Add("[email protected]<mailto:[email protected]>") $MailMessage.Subject = "DAG Not Healthy!" $MailMessage.Body = $body $MailMessage.Priority = "High" $SMTPClient = New-Object System.Net.Mail.SMTPClient $SMTPClient.Host = "HTCAS1.letsexchange.com" $SMTPClient.Send($MailMessage) } Function getExchangeServerADSite ([String] $excServer) { # We could use WMI to check for the domain, but I think this method is better # Get-WmiObject Win32_NTDomain -ComputerName $excServer $configNC=([ADSI]"LDAP://RootDse").configurationNamingContext $search = new-object DirectoryServices.DirectorySearcher([ADSI]"LDAP://$configNC") $search.Filter = "(&(objectClass=msExchExchangeServer)(name=$excServer))" $search.PageSize = 1000 [Void] $search.PropertiesToLoad.Add("msExchServerSite") Try { $adSite = [String] ($search.FindOne()).Properties.Item("msExchServerSite") Return ($adSite.Split(",")[0]).Substring(3) } Catch { Return $null } } [Bool] $bolFailover = $False [String] $errMessage = $null Get-MailboxDatabase | Sort Name | ForEach { $db = $_.Name $curServer = $_.Server.Name $ownServer = $_.ActivationPreference | ? {$_.Value -eq 1} # Compare the server where the DB is currently active to the server where it should be If ($curServer -ne $ownServer.Key) { # Compare the AD sites of both servers $siteCur = getExchangeServerADSite $curServer $siteOwn = getExchangeServerADSite $ownServer.Key If ($siteCur -ne $null -and $siteOwn -ne $null -and $siteCur -ne $siteOwn) { $errMessage += "`n$db on $curServer should be on $($ownServer.Key) (DIFFERENT AD SITE: $siteCur)!" } Else { $errMessage += "`n$db on $curServer should be on $($ownServer.Key)!" } $bolFailover = $True } } $errMessage += "`n`n" Get-MailboxServer | Get-MailboxDatabaseCopyStatus | ForEach { If ($_.Status -notmatch "Mounted" -and $_.Status -notmatch "Healthy" -or $_.ContentIndexState -notmatch "Healthy") { $errMessage += "`n$($_.Name) - Status: $($_.Status) - Index: $($_.ContentIndexState)" $bolFailover = $True } } If ($bolFailover) { sendEmail $errMessage #Schtasks.exe /Delete /TN "MonitorDAG" /F } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
