Check out the full list of Set-AdServerSettings parameters here.

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

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

RunspaceId : 15e4d968-032b-4cd8-bc66-bf0b665c4161

DefaultGlobalCatalog : DC1.exchangeserver.local

PreferredDomainControllerForDomain : {}

DefaultConfigurationDomainController : DC1.exchangeserver.local

DefaultPreferredDomainControllers : {DC1.exchangeserver.local}

UserPreferredGlobalCatalog :

UserPreferredConfigurationDomainController :

UserPreferredDomainControllers : {}

RecipientViewRoot : exchangeserver.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.exchangeserver.local

Now Get-ADServerSettings shows this change has occurred.

[PS] C:\>Get-ADServerSettings | fl
 
RunspaceId                                 : b15cbfd9-5144-442e-bc74-c00a3216b864
DefaultGlobalCatalog                       : dc2.exchangeserver.local
PreferredDomainControllerForDomain         : {}
DefaultConfigurationDomainController       : dc2.exchangeserver.local
DefaultPreferredDomainControllers          : {DC1.exchangeserver.local}
UserPreferredGlobalCatalog                 : dc2.exchangeserver.local
UserPreferredConfigurationDomainController : dc2.exchangeserver.local
UserPreferredDomainControllers             : {dc2.exchangeserver.local}
RecipientViewRoot                          : exchangeserver.local
ViewEntireForest                           : False
Identity                                   :
IsValid                                    : True
 
Advertisements