Tuesday, June 14, 2016

Add All Exchange 2016 Servers from the Site to DAG

Hi folks,

Just wanted to share with you with a script on how to quickly add new Exchange 2016 servers into DAG. Let's imagine scenario when you have introduced Exchange 2016 CU1 servers into an AD site which currently contains Exchange 2010 and 2013 servers. Let's also imagine that we have a proper and consistent naming convention (believe me, folks, it makes life sooooo easy). And of course let's assume that we have a good network infrastructure and fast AD replication.

If all of the above is truth and you are lazy to type command for each server or click Next button million of times then the below code is exactly for you. I made this script interactive so that you will need to type the name of your DAG (perhaps you have more than one AD site where you introduce Exchange servers with a different DAG in it). By this you won't need to edit this script every time when you move from site to site. Then you feed all your Exchange 2016 servers with the version "Version 15.1 (Build 396.30)" into the variable and then add them one by one. To allow AD replication occur (you know sometimes Microsoft Clustering solution are a bit temperamental and sensitive to the AD) I added 20 min for replication after each servers are added. This will allow you to kick of the script and have some time for drinking tea or reading TechNet :).

The code will look something like below:


$DAG = Read-Host "Type your DAG Name. For example: DAG01"
$ExchBox = Get-ExchangeServer $DAGSrv* | Where-Object {$_.AdminDisplayVersion -like "Version 15.1 (Build 396.30)"}
   $ExchBox |foreach {
                                      Start-Sleep -Seconds 600
                                       Add-DatabaseAvailabilityGroupServer -Identity $DAG -MailboxServer $_.Name
                                       Start-Sleep -Seconds 600}

Enjoy!

No comments:

Post a Comment