#Powershell script to check #Exchange 2010 Database Perference

#Exchange2010

So we all should know about Exchange Server 2010 Database Availability Groups (DAG).  Now when you add server to a DAG you assign an ActivationPreference number to each server.

The ActivationPreference parameter value is used to break ties during the automatic database activation process when multiple passive mailbox database copies meet the same criteria for activating. When multiple database copies meet the same criteria for activation the copy assigned the lowest activation preference number will be activated. The value for ActivationPreference is a number equal to or greater than 1, where 1 is at the top of the preference order. The position number cannot be larger than the number of database copies of the mailbox database plus 1.

You would also know that Exchange handles the DAG and will failover databases to other servers in the DAG that have a database copy.

Now this is cool and works like a dream, but what if, as in my case, you actually want the database to be on a preferred server?

Well I knocked up this one liner to check it!

Get-MailboxDatabase | Sort Name | FOREACH {$db=$_.Name; $xNow=$_.Server.Name ;$dbown=$_.ActivationPreference| Where {$_.Value -eq 1};  Write-Host $db “on” $xNow “Should be on” $dbOwn.Key -NoNewLine; If ( $xNow -ne $dbOwn.Key){Write-host ” WRONG” -ForegroundColor Red; }ELSE{Write-Host ” OK” -Foregroundcolor Green}}

Enjoy .. let me know what you think

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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.