Friday, December 3, 2010

Failback Exchange 2010 DAG with Powershell

Exchange 2010 DAG will do failover, that is switch to a backup server when the primary goes down.
But for whatever reason the genius at Microsoft decided not to enable failback, that is return to primary when it comes back.

However this is fairly easy to script up in PowerShell:

Add-PSSnapIn "Microsoft.Exchange.Management.PowerShell.E2010"
Move-ActiveMailboxDatabase -identity "database name" -ActivateOnServer "SERVERNAME" -Confirm:$false

Configure the task in Task Scheduler using New Basic Task. When you open the properties tab select Run whether the user is logged in or not and make sure to select Use highest privilege level.

For the trigger use Event ID 2157.