How to Use a Specific Domain Controller in Exchange 2010 Management Shell

In a recent post I looked at how to specify a domain controller for use in the Exchange Management Shell for Exchange Server 2007.  In this post I will demonstrate the same technique for Exchange Server 2010.

Any Exchange Management Shell cmdlet will permit you to specify a domain controller using the -DomainController switch.  But you can also set a preferred domain controller for your entire session.

Note the cmdlet to use here – Set-AdServerSettings. This cmdlet configures the session settings such as the preferred Domain Controller and other settings such as the recipient scope.  Check out the full list of Set-AdServerSettings parameters here.

First take a look at the current session settings. In this example dc1.exchangeserverpro.local has been automatically selected.

[PS] C:\>Get-ADServerSettings | fl

RunspaceId                                 : 15e4d968-032b-4cd8-bc66-bf0b665c4161
DefaultGlobalCatalog                       : DC1.exchangeserverpro.local
PreferredDomainControllerForDomain         : {}
DefaultConfigurationDomainController       : DC1.exchangeserverpro.local
DefaultPreferredDomainControllers          : {DC1.exchangeserverpro.local}
UserPreferredGlobalCatalog                 :
UserPreferredConfigurationDomainController :
UserPreferredDomainControllers             : {}
RecipientViewRoot                          : exchangeserverpro.local
ViewEntireForest                           : False
Identity                                   :
IsValid                                    : True

Using Set-ADServerSettings we can specify the preferred server for the current session with the -PreferredServer switch.

[PS] C:\>Set-ADServerSettings -PreferredServer dc2.exchangeserverpro.local

Now Get-ADServerSettings shows this change has occurred.

[PS] C:\>Get-ADServerSettings | fl

RunspaceId                                 : b15cbfd9-5144-442e-bc74-c00a3216b864
DefaultGlobalCatalog                       : dc2.exchangeserverpro.local
PreferredDomainControllerForDomain         : {}
DefaultConfigurationDomainController       : dc2.exchangeserverpro.local
DefaultPreferredDomainControllers          : {DC1.exchangeserverpro.local}
UserPreferredGlobalCatalog                 : dc2.exchangeserverpro.local
UserPreferredConfigurationDomainController : dc2.exchangeserverpro.local
UserPreferredDomainControllers             : {dc2.exchangeserverpro.local}
RecipientViewRoot                          : exchangeserverpro.local
ViewEntireForest                           : False
Identity                                   :
IsValid                                    : True
About Paul Cunningham

Paul is a Microsoft Exchange Server specialist for one of Australia's largest companies, and is the Publisher of ExchangeServerPro.com. He is also an MCP, MCSA, MCSE, MCTS, and an MCITP for Exchange Server 2007/2010. Connect with Paul on Twitter and LinkedIn.

Comments

  1. You may or may not see this issue I had on Exchange 2007 but good to refer to: http://bit.ly/5KKRXX – Exchange 2007 Setup Error: Setup Cannot use Domain Controller

  2. Daniel says:

    Why the option DefaultPreferredDomainControllers keeps pointing to : {DC1.exchangeserverpro.local}? I have a lab environment that there are two dcs. I would like to demote one of them, but the exc keeps connected on it like your example. And I’ve changed the GC. :)

  3. Hamid says:

    what is the difference if i try to do the same job using the Set-ExchangeServer cmdlet.

    for example : Set-ExchangeServer -Identity -StaticDomainControllers dc1.mydomain.ad,dc2.mydomain.ad

    by the way, your blog is really one of my favorite one :-)

    • Set-ExchangeServer sets server settings that the server itself uses for AD access.

      Set-AdServerSettings sets the settings for your Exchange Management Shell session. Eg if you were running the shell on your admin workstation.

  4. Junaid Ahmed says:

    Thanks man!! :)

  5. Rich says:

    When I run the script “Set-ADServerSettings -PreferredServer pdc.domain.com”, it changes the data to what I expected when I run the “Get-ADServerSettings | fl “however when I close the EMS and re-open it and run the “Get-ADServersettings | fl” script it shows the old configuration for “dns.domain.com”.
    I have checked that the EMS is running “as administrator” and checked that the administrator can change the Exchange server.
    The system log files show that the changes took place but it appears it is not working as expected. Am I missing something?
    This is a new Exchange 2010 SP1 on Server 2008 R2 in a New Domain/Forest. I have check that it is fully patched, and that the DC’s are fully patched and the DC’s are both GC’s. I am runing this via a RDP, do I have to run it at the Exchange console?
    Any help would be appreciated.

Leave a Comment

*