Home » Exchange Server » How to Use a Specific Domain Controller in the Exchange 2007 Management Shell

How to Use a Specific Domain Controller in the Exchange 2007 Management Shell

I read this recent post at Jim McBee’s Mostly Exchange blog about how to specify a domain controller when issuing Exchange Management Shell commands. After battling the Blogger comments system for a few minutes I gave up and decided to write this blog post instead.

Jim notes that the shell will generally choose the closest domain controller, which is not always the most appropriate one depending on the administrative tasks you are planning to execute.

Jim points out that you can add the -DomainController argument to any EMS cmdlet, which will resolve the issue for that specific command.  However there are two other ways to address this issue.

One way is to modify the $AdminSessionADSettings settings, which can be seen from the shell.

Note these two settings:

  • ConfigurationDomainController – lets you hard code a DC to use for shell cmdlets
  • PreferredDomainControllers – lets you specify one or more preferred DC’s for shell cmdlets to use. If a domain is specified that is not served by one of these preferred DC’s one will be chosen automatically.

Modifying the settings is simple.

Any DC that you specify here must be valid or an error will appear and the change rejected.

Modifying $AdminSessionADSettings applies to the current session only. To make these changes apply to all EMC sessions that the administrator launches you must edit the BinExchange.ps1 file in the Exchange Server installation folder. Look for this line in the file:

Then simply append any additional settings after it.

This change will then take affect for all future Exchange Management Shell sessions on that server.

Paul is a Microsoft MVP for Office Servers and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul is a co-author of Office 365 for IT Pros and several other books, and is also a Pluralsight author.
Category: Exchange Server


  1. Martin Gauvreau says:

    Thanks Paul. You saved my life, and my job!
    I accidently deleted some important VMs files from our ESX Storage. Since then, our DC is down and therefore Exchange wasn’t working.


  2. Server System Engineer says:


    I need to migrate all of my Exchange Server 2007 from one AD site into another one within the same AD domain, so shall I do the following Registry changes first:

    Key: SystemCurrentControlSetServicesNetlogonParameters
    Name: New-AD-SiteName
    Type: REG_SZ

    followed by the below Powershell command:

    Set-ExchangeServer -Identity PRODExcMBX1 -StaticConfigDomainController PRODDC1 -StaticGlobalCatalogs PRODDC1
    Set-ExchangeServer -Identity PRODExcMBX1 -StaticConfigDomainController PRODDC2 -StaticGlobalCatalogs PRODDC2

  3. Jimmy Bowers says:

    I demoted an old 2003 DC and now it is just a member server, upgraded the function level to 2008 and now my exchange server does not see any DCs.
    I ran the following command and it failed with any Domain Controller and they all have Global Catalogs;
    $AdminSessionADSettings.PrefferedDomainController =
    Can you help me please?

Leave a Reply

Your email address will not be published. Required fields are marked *