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