Share via


Exchange Server Database Status Report in Daily Email Notification

Summary

Email Services are very important for every Exchange Server administrator in any IT infrastructure, and Exchange Server Databases are one of the most crucial subject for every admin to be well aware about Exchange Server databases Health, Mount Status, CopyQueueLength ReplayQueueLength and LastInspectedLogTime etc. In this topic we will walk through the steps to schedule a task which can bring some great information for Exchange administrator in his/her mailbox as daily email notification so that he can have a look into it even he/she is busy in his routine jobs and don't have time to get inside the Exchange Server or doing a remote PowerShell to know Exchange Databases Health and mounting status.

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:-

  • ExchangeDatabaseCopyStatus.bat
  • ExchangeDatabaseCopyStatus.PS1

Creating .bat File

Open the ExchangeDatabaseCopyStatus.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:\

PowerShell.exe -PSConsoleFile "D:\Program Files\Microsoft\Exchange Server\V15\Bin\ExShell.psc1" -Command ". 'C:\Program Files\Update Services\Exchange Bats\Exchange Bats\ExchangeDatabaseCopyStatus.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 2nd part of the command is the path of your .PS1 script where you place it.

Creating .PS1 Script

We will open the ExchangeDatabaseCopyStatus.PS1 script in any editor and fill the following information.

$messageParameters = @{
    Subject = "Exchange 2013 Mailbox Copy Status Report - $((Get-Date).ToShortDateString())"
    Body =  Get-MailboxServer |
   ForEach-Object { Get-MailboxDatabaseCopyStatus -Server $_ |
   Select-Object Name, Status, CopyQueueLength, ReplayQueueLength, LastInspectedLogTime} |
   Sort-Object Name |
         ConvertTo-Html |
         Out-String
    From = "Exchange-DB-Status@mstechguru.ae"
    To = "Exchange-admins@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 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 about Exchange Server's Databases Health and 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 daily basis at particular time like when 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 Heath & status.

Scheduling a Task in Exchange

Open the Task Scheduler and click Create Basic Task

Click Next, select Daily and click Next

Click Next, select the Date and time as per your time zone and click Next

Select Start a Program and click Next

Click Next

You can select the path of your Bat file where you place it

"C:\Program Files\Update Services\Exchange Bats\Exchange Bats\ExchangeDatabaseCopyStatus.bat"

Click Next Click

Open the Properties dialog checkbox and click Finish

Go to Trigger and click Edit to edit the condition, you can review the schedule and finish the task.

Results in Email

When task will trigger you will receive an email having Exchange Servers all Databases with status.

Conclusions

This will help Exchange administrators to automate tasks and get results in his/her inbox on daily basis. Admin can also have a history of the Heath status of Exchange Databases in his/her inbox