Exchange Server 2013 Backup status and Database Size log status


The below script will helps to provide the detail on number of mailboxes in each database, database size, incremental backup status and full backup status. The output of the file will be saved in the desktop and also it will sent as email with an attachment

# Where to store output
$savefile  = $env:USERPROFILE + ‘\Desktop\’ +((Get-Date).ToString(“dd_MM_yyyy_HHmm”))+’.html’

#Preformat HTML document
$a = “<style>”
$a = $a + “BODY{background-color:peachpuff;}”
$a = $a + “TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}”
$a = $a + “TH{border-width: 1px;text-align: center; margin: 2px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}”
$a = $a + “TD{border-width: 1px;text-align: center; margin: 2px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}”
$a = $a + “</style>”

# Function to for the Output

$Output = Get-MailboxDatabase -status | Select Name,@{Name=”NumberofUsers”;Expression={(Get-Mailbox -resultsize unlimited -Database $_.name).Count}},LastIncrementalBackup,LastFullBackup,Databasesize | ConvertTo-Html -head $a -body “<H2> Mailbox Count & Database Size Status</H2>”

$Report = $Output |Out-File $savefile

# this will open report in your default browser.
#Invoke-Item  $savefile

#To Send Email

$MailTo = “Raji.Subramanian@mail.com”
$MailFrom = “Admin@mail.com”
$MailServer = “Exserver.mail.com”

Send-MailMessage -Attachments $savefile -To $MailTo -From $MailFrom -Subject “Exchange 2013 Database Size and Backup Status Report” -Body ( $Output | out-string ) -bodyashtml -SmtpServer $MailServer

To add them in the task schedule copy the below command and paste them in the command of new task

C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -Command “.’E:\Program Files\Microsoft\Exchange Server\V15\Bin\RemoteExchange.ps1′; Connect-ExchangeServer -auto; C:\Scripts\DB_Size.ps1

Advertisements

About Raji Subramanian

Nothing great to say about me...Just want to share my knowledge for others that will be useful at any moment of time when they stuck in critical issue....
This entry was posted in Exchange Server 2013 Cumulative Update 6 Released, Script and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s