Archive for August, 2010

Automatically Fixing FailedAndSuspended Exchange 2010 Databases with PowerShell

No Comments » Written on August 18th, 2010 by
Categories: Exchange, PowerShell
Tags: , ,
Another quick script, this one finds all databases located on Exchange 2010 servers with a status of ‘FailedAndSuspended’ and then reseeds them. Since this scripts makes changes to the systems, instead of just reading information, all activities are logged via PowerShell’s transcript feature. You’ll need to change the path in the 5th line of the script to reflect an actual location on your system.
Note that there are other options besides a reseed, this just makes the most sense the majority of the time.

add-pssnapin *0* -ErrorAction SilentlyContinue
$startstring="Start script run at:  "
$startendtime=date
$startannounce=$startstring+$startendtime
Start-Transcript -Append -Force -Path 'C:\<path>\DBHealthFix.log'
$startannounce
#gets list of mailboxservers, locates 2010 servers, gets db copy status, finds copies that are failed, updates failed copies
$mailboxservers = get-mailboxserver | get-exchangeserver | ?{$_.IsE14OrLater -eq 'True'}
foreach ($mailboxserver in $mailboxservers){
get-mailboxdatabasecopystatus -Server $mailboxserver.name | ?{$_.Status -like 'FailedAndSuspended'} | update-mailboxdatabasecopy -deleteexistingfiles -confirm:$false
}
stop-transcript

Here are some screenshots of what happens along the way:

The script shown in the first and last screenshot is available here.

Checking Exchange 2010 Database Health with PowerShell

1 Comment » Written on August 18th, 2010 by
Categories: Exchange, PowerShell
Tags: , ,

Just a quick script that checks your database health. Anything besides ‘Healthy’ or ‘Mounted’ should probably be investigated. :)

Add-PSSnapin *0* -ErrorAction SilentlyContinue
$mailboxservers = get-mailboxserver | get-exchangeserver | ?{$_.IsE14OrLater -eq 'True'}
$A = (get-host).UI.RawUI
$A.WindowTitle = "Database Health Check"
$B = $A.windowsize
$B.width = 110
$B.height = 30
$A.WindowSize = $B
while ($true) {cls; foreach ($mailboxserver in $mailboxservers){Get-MailboxDatabaseCopyStatus -Server $mailboxserver.name | ft -AutoSize Name,*Status,ContentIndexState,CopyQueueLength,ReplayQueueLength} ;sleep 5}

This it the output, refreshed every 5 seconds:

An example of when databases are actually doing something: