I needed a quick and dirty method to add database copies to other servers in an Exchange 2010 Database Availability Group (DAG). I had three servers, each with 10 databases. Each one of those databases should have a copy on the other two servers.
Now, this is painful if you have to use the GUI to do it – not that it takes a lot, but it’s time consuming. The Add-MailboxDatabaseCopy cmdlet is very helpful in PowerShell, but still I wanted to automate it since my naming conventions were pretty standard.
So, I wrote a PowerShell script to automate this process. Essentially, the script has a few variables and I dome some loop magic to drop everything into place.
This script is quick and dirty for a lab environment. Keep in mind that this doesn’t do any error checking and there is no validation to see if a database is already homed to a server. This just uses the cmdlet to try to create the database copy; if it is successful, you’re good to go. If it fails, the script just keeps on rolling. No harm, no foul.