Here is a simple script you can use to check the last backup time for the mailbox databases on an Exchange Server. Run the script from the Exchange Management Shell on a Mailbox Server to check the local server’s databases.
[PS] C:\Scripts>.\check-dbbackups.ps1 Server: ESP-HO-EX2010B Current time: 03/27/2011 22:21:39 Database Last Full (hrs ago) Last Inc (hrs ago) -------- ------------------- ------------------ MB-HO-01 1 n/a MB-HO-02 1 n/a MB-HO-Archive-01 n/a n/a
Here is the script code.
$server = $env:computername
$now = [DateTime]::Now
"Server: " + $server
"Current time: " + $now
$db = get-MailboxDatabase -server $server -status
foreach ($objItem in $db)
{
$lastfull = $objItem.lastfullbackup
if (!$lastfull)
{
$fullago = "n/a"
}
else
{
$fullago = $now - $lastfull
$fullago = $fullago.TotalHours
$fullago = "{0:N0}" -f $fullago
}
$lastinc = $objItem.lastincrementalbackup
if (!$lastinc)
{
$incago = "n/a"
}
else
{
$incago = $now - $lastinc
$incago = $incago.TotalHours
$incago = "{0:N0}" -f $incago
}
$returnedObj = new-object PSObject
$returnedObj | add-member NoteProperty -name "Database" -value $objItem.Name
$returnedObj | add-member NoteProperty -name "Last Full (hrs ago)" -value $fullago
$returnedObj | Add-Member NoteProperty -name "Last Inc (hrs ago)" -value $incago
$returnedObj
}




Great script! Simplicity is always a key feature!