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

by Paul Cunningham on November 19, 2009

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.

[PS] C:\>$AdminSessionADSettings

ViewEntireForest              : False
DefaultScope                  : contoso.com
PreferredGlobalCatalog        :
ConfigurationDomainController : exch2007.contoso.com
PreferredDomainControllers    : {}

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.

[PS] C:\>$AdminSessionADSettings.ConfigurationDomainController = 'dc1.contoso.com'
[PS] C:\>$AdminSessionADSettings.PreferredDomainControllers = 'dc1.contoso.com','dc2.contoso.com'

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 Bin\Exchange.ps1 file in the Exchange Server installation folder. Look for this line in the file:

$global:AdminSessionADSettings.ViewEntireForest = $false

Then simply append any additional settings after it.

$global:AdminSessionADSettings.ViewEntireForest = $false
$global:AdminSessionADSettings.ConfigurationDomainController = 'dc1.contoso.com'

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

Did you find this post useful? If so please leave a comment below. You may also subscribe to the RSS feed to receive new posts automatically.

{ 1 trackback }

How to Use a Specific Domain Controller in Exchange 2010 Management Shell | Exchange Server Pro
November 30, 2009 at 8:22 pm

{ 0 comments… add one now }

Leave a Comment