Exchange Server Database Size & LastFullBackup Report in Daily Email Notification
Summary
In a Microsoft Exchange Server environment the database growing size and the backup status is one of the most important information for Exchange administrator. In a very large environment where we have more than 50 databases or where we are running Exchange as a hosted solution and running multi companies, we must have to keep an eye on Exchange Server growing databases and full backup status. Many backup solutions are providing notifications alerts on a successful backup job but we can get the daily email alert on each database size and last backup date and time.
In this article, we will walk through the steps to schedule a script in Task Scheduler so that we can get Exchange Server DatabaseSize and LastFullBackup report in administrator inbox on daily basis.
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:-
- ExchangeDatabaseSizeLastFullBackupStatus.bat
- ExchangeDatabaseSizeLastFullBackupStatus.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\ExchangeDatabaseSizeLastFullBackupStatus.PS1'"
You can point to this PowerShell.exe where your Exchange is installed. In this case, it's 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 .PS1 Script
We will open the ExchangeDatabaseCopyStatus.PS1 script in any editor and fill the following information.
$messageParameters = @{
Subject = "Exchange 2013 DatabaseSize LastFullBackup Report - $((Get-Date).ToShortDateString())"
Body = Get-MailboxDatabase -status |
Select-Object Server, Name, databasesize, Mounted, LastFullBackup |
Sort-Object Server, Name |
ConvertTo-Html |
Out-String
From = "Exchange-DBSize-LastBackup@mstechguru.ae"
To = "administrator@mstechguru.ae"
SmtpServer = "smtp.mstechguru.ae"
}
Send-MailMessage @messageParameters -BodyAsHtml
In the 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 the organization, so They will receive email notification on daily basis and be well aware of Exchange Server's Databases growing Size Name and LastFullBackup status.
Scheduling a Task in Exchange
Task scheduling steps can follow from the below link:
Scheduling A Task in Exchange Server
Results in Email
When task will trigger you will receive an email having Exchange Servers all Databases with status.
Conclusion
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 DatabaseSize for each day and status of Exchange Databases backup in his/her inbox