#Exchange2010 #Powershell
So I wanted to share this. Our outsource provider is suppose to monitor Exchange Server backups and disk space, but when an Exchange 2003 storage group dismounted alarm bells started to ring .. and guess what, the log drive filled up, as a backup had failed and not run for a week !
So we have a mixed Exchange 2003, 2007, 2010 environment, and I was playing with the Exchange Server 2010 management shell and knocked this script up to create a HTML page for all database backups and then email it to me.
The output is a HTML file called Get-ExchangeBackupStatus.html but that is really optional as the email is what you really want
#Using Exchange 2010 Powershell addin
$Error.Clear()
$xPsCheck = Get-PSSnapin | Select Name | Where {$_.Name -Like “*Exchange*”}
If ($xPsCheck -eq $Null) {Add-PsSnapin Microsoft.Exchange.Management.PowerShell.e2010}
$backupstatus = Get-MailboxDatabase -Status -IncludePreExchange2010 | select ServerName, Name, lastFul* | sort LastFullBackup, Name
$y=Get-Date
$x=”
TABLE{font-family:VERDANA;font-size: 10pt;border-width: 1px;padding: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TD{border-width: 1px;padding: 1px;border-style: solid;border-color: black;}
TH{border-width: 1px;padding: 1px;border-style: solid;border-color: black;background-color:peachpuff;}
“;
$z=”Exchange Backup Status
Last updated: $y
”
$htmltxt = $backupstatus | ConvertTo-Html -head $x -Title “Exchange Server Database Status” -body $z -PreContent “”
$htmltxt |OUT-FILE Get-ExchangeBackupStatus.html
#Email the html file
$msgBody = $htmltxt
$subject = “PSM: Exchange Server Backup ” + $y
$emailTo = “** Email to goes here **”
$emailFrom = “** Emal from goes here **”
$SMTPServer = “** SMTP Server Name Goes Here **”
$message = New-Object Net.Mail.MailMessage($emailFrom, $emailTo, $subject, $msgbody)
$message.IsBodyHTML = $true
$smtp = New-Object Net.Mail.SmtpClient($SMTPServer )
$smtp.Send($message)
Enjoy! .. as for the html file, I have some more posts coming soon, for an Exchange 2010 monitoring website driven by Windows Powershell (we don’t have SCOM to make life easier!)