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




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
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.
Hi Daniel,
you have to run this command
set-adserversettings -configurationdomaincontroller
paul used the preferreddomaincontroller switch.
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.
Thanks man!!
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.
Hi Rich, Set-ADServerSettings applies only to the current session.
If you want the setting to be applied each time you open a new session you could look at using a PowerShell profile:
http://technet.microsoft.com/en-us/library/ee692764.aspx
Good day brother,
how do i change this to “DC1.exchangeserverpro.local”
DefaultConfigurationDomainController : dc2.exchangeserverpro.local
Please help – this is were i stand now..
Hi Paul,
if i’m not looking at demoting or removing any AD servers in my site, i was wondering if there was a valid reason why i would change the ADServerSettings.
I recently had a PFE do a ExRap and one of his recommendation was ” not to point exchange to a PDC emulator”
in each of my remote sites, i have 2 DCs both of which are GCs but only one is the PDC. my concern is if the 2nd “none PDC DC” goes down, my exchange gets affected.
i guess what i’m asking is ” is there a reason why i would change it to point to a single DC ?” when nothing else is changing.
sorry about the whole bunch of acronyms.
Cheers,
Ed