Thursday, October 6, 2016

Which Domain Controller Can I Use for My EMS Commands

Hi folks,

I have previosly discussed how to use PowerShell commands (from the AD module) to discover domain controllers in an AD site. You can read about it in this post.

The same is possible to do by using EMS. In some of the cases when you are running multiple commands and dependent on the AD replication before running the next command it is nice to write all changes to the same AD command. MS has nicely provided -DomainController parameter which allows us to perform any reading/writing of Exchange information against the same domain controller. All you need is to specify DC host name.

Now if you have multiple domains or a lot of domain controllers within AD site where your Exchange server is located (or workstation with Exchange admin tools) you can use the Get-DomainController cmdlet to discover them. You can read about this cmdlet and all the available parameters here. Let's imagine that my Exchange server is located in the AD site called New York and in multi-domain forest. I need to write to a DC in the domain. Then the following command will be used:

Get-DomainController -DomainName |Where-Object {$_.AdSite -like "*NewYork*"} |select DnsHostName

It is pretty obvious. However, let me explain why I used filter for AdSite parameter and asked command to output DnsHostName parameter. Usually Get-DomainController returns distinguished value for AD site something like York. The same applies for domain controllers' parameter called Identity parameter of domain controller. It will be something like York/NYDC01. DnsHostName parameter will retrieve FQDN of DC which you can later use as value for the -DomainController parameter, like

I hope you will find this useful for your PowerShell adventures.