Quickly setting up an Exchange 2010 or 2013 DAG cluster…

So, you’ve installed a couple of Exchange 2010 or 2013 servers and want to setup DAG quick and easy…

Well, just copy/paste these powershell commands (and edit the few parameters that can vary from your installation and you’re good to go.

Create DAG cluster

New-DatabaseAvailabilityGroup -Name <network name of DAG cluster> -WitnessServer <Netbios name of witness server> -WitnessDirectory <local path on witness server to where you want the witness directory stored> -DatabaseAvailabilityGroupIPAddresses <IP address of DAG cluster>

This will form the DAG cluster.

Add nodes to DAG cluster

Add-DatabaseAvailabilityGroupServer -Id <netbios name of DAG cluster> -MailboxServer <Netbios name of server to be added>

This will add the server in question to the DAG cluster and the command must be run once per server to be added (unless you use an answer file, but I won’t cover that here).

Create databases

New-MailboxDatabase -Name <Name of mailbox database> -EDBFilePath <Local path to where you want the file stored, remember to include filename and extension of the EDB file> -LogFolderPath <Local path to where you want the log files to be created>

This will create the databases you want. Remember that the paths chosen above must be available on all servers.

Move arbitration, system or discovery mailboxes to the newly created databases

Get-MailboxDatabase -Arbitration | New-MoveRequest -TargetDatabase <name of target mailbox database>

This will start to move the arbitration mailboxes to the selected database. Use this only if you want to delete the default database. Otherwise, continue to “Add database copies to database”

Check status the move requests created above


This will show the status of the move requests created above. Once they all lists as completed, you can go ahead and delete them as I will show below.

Delete the move requests created above

Get-MoveRequest | Remove-MoveRequest

This will remove the move requests listed above and you will be able to delete the default database created during installation.

Cleanup disconnected mailboxes

Get-MailboxStatistics –Database <name of database to be removed> | Where-Object {$_.DisconnectReason –eq ‘Softdeleted’} | ForEach {Remove-StoreMailbox –Database $_.database –identity $_.mailboxguid –MailboxState Softdeleted

Remove default database

Remove-MailboxDatabase -Identity <Name of the database you wish to remove>

This will remove the database specified. This must be done once per DAG node you installed, as each mailbox server that is installed will create a default database.

Add database copies to databases

Get-MailboxDatabase | Where-Object {$_.replicationtype -ne ‘Remote’} | Add-MailboxDatabaseCopy -MailboxServer <Netbios name of server to be added> -ActivationPreference <activation preference in number form>

This command adds the mailbox database copy to the server in question. Off course the server must be added as a DAG node as done above. I’ve purposely built the command to scan for non-replicated databases, so it can be used on a later occasion if you add more databases.
The activation prefence lists in what order you want the servers to activate the database, for example 1 is primary, 2 is secondary, 3 is tertiary and so on. If you are adding more than one additional server, the above command can also be used by appending | Add-MailboxDatabaseCopy -MailboxServer <Netbios name of server to be added> -ActivationPreference <activation preference in number form> and simply change the server name as well as increment the activation preference number.

With these steps, you have a running Exchange 2010 or 2013 DAG cluster and are ready to deploy mailboxes on these…

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 )

Google photo

You are commenting using your Google 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.