Exchange Server Database Replication Status Report in Daily Email Notification
Summary
In Database Availability Group environment where we have copies of database on other Exchange Server for continuous replication of the active Databases. We can use the Test-ReplicationHealth cmdlet to view continuous replication status information about mailbox database copies, but for this we need to access the Exchange Server or its remote PowerShell to see the results of Databases Replication status. This cmdlet can be used to check all aspects of the replication and replay status to provide a complete overview of a specific Mailbox server in a DAG environment. The Test-ReplicationHealth cmdlet is designed for the proactive monitoring of continuous replication and the continuous replication pipeline, the availability of Active Manager, and the health and status of the underlying cluster service, quorum, and network components. It can be run locally on or remotely against any Mailbox server in a DAG. The Test-ReplicationHealth cmdlet performs the tests listed below:-
Replication Tests
These tests will be performed when we run the script in Exchange Server:-
• ClusterService
• ReplayService
• ActiveManager
• TasksRpcListener
• TcpListener
• ServerLocatorService
• DagMembersUp
• MonitoringService
• ClusterNetwork
• QuorumGroup
• FileShareQuorum
• DatabaseRedundancy
• DatabaseAvailability
• DBCopySuspended
• DBCopyFailed
• DBInitializing
• DBDisconnected
• DBLogCopyKeepingUp
• DBLogReplayKeepingUp
Steps
We need to create two files and keep them somewhere in your Exchange drives my docs, download or C:\ drive etc where you have full permission to run these file in-case if you have used delegated account for Exchange installation. File names with extension are as below:-
- ExchangeTest-Replication.bat
- ExchangeTest-Replication.PS1
Creating .bat File
Open the ExchangeTestMAPIConnectivityLatency.bat file and paste the following path which can vary to your environment, or as per your Exchange application installation. Most of the people install Exchange Server in default OS drive C:\
PSConsoleFile "D:\Program Files\Microsoft\Exchange Server\V15\Bin\ExShell.psc1" -Command ". 'C:\Program Files\Update Services\Exchange Bats\Exchange Bats\ExchangeTest-Replication.PS1'"
You can point to this PowerShell.exe where your Exchange is installed. In this case, its installed in D:\ so its using that path, the second part of the command is the path of your .PS1 script where you place it.
Creating a .PS1 Script
We will open the ExchangeTestMAPIConnectivityLatency.PS1 script in any editor and fill the following information.
$messageParameters = @{
Subject = "Exchange 2013 Replication Status Report - $((Get-Date).ToShortDateString())"
Body = Test-ReplicationHealth -server rgr1-mbx01 |
ConvertTo-Html |
Out-String
From = "Exchange-DB-Status@mstechguru.ae"
To = "administrator@mstechguru.ae"
SmtpServer = "smtp.mstechguru.ae"
}
Send-MailMessage @messageParameters -BodyAsHtml
In Script you can change Subject value, From Value, To Value and SmtpServer value as per your environment. In From value, we can put any dummy email ID which will later appear in Email from the option. So no need to put any valid email address in From. In To option we have to put some valid email address for Exchange Administrator or the Exchange admins teams who are responsible for Exchange Servers in organization, so They will receive email notification on daily basis and be well aware of Exchange Server's Database Replication Status.
Note:- In SMTP setting you can put your CAS Server FQDN if you are running Exchange 2013, and for Exchange Server 2016 you can put FQDN of your any Mail-box Server. At this point, we have created both files and keep them in C:\ drive somewhere. Now we will create a Schedule Task to run this .bat file on a daily basis at a particular time like when an administrator takes coffee or tea at morning he/she can schedule this at that time to have a view to his inbox for Exchange Databases Replication & status. Scheduling a Task in Exchange How you schedule your task for this .bat file to run, you can follow the link below:-
Scheduling a Task in Exchange
How you schedule your task for this .bat file to run, you can follow the link below:-
Results in Email
When task will trigger you will receive an email having Exchange Servers all Databases Replication Testing status.
This will help you to keep an eye on Exchange DB Replication Test status in the mail notifications, so that Exchange administrator can also have a record of each day replication status. We can also schedule this for two times in a day for more critical Exchange environments.