I must admit, I love Exchange, and the first look I had on Exchange 2007, I was feeling very uneasy when faced with the Exchange Management Shell. But second thing to admit, after working with the shell for almost two years now, I love the power of this thing with the perfect name: POWERShell 🙂
As an Exchange administrator, it is hard not to get familiar with the Shell. And I will try to post in this blog some tips that will be useful for you as an exchange administrator, and hopefully make some PowerShell addicts have a look at this great messaging product Exchange is now, (and have to admit, always has been ;-))
$AdminSessionAdSettings
When you start the Exchange Management Shell, you will notice that by default you will be connected to a domain controller and that the scope is set to the domain you’re logged on to. When looking at the script that is executed when launching the shell, you will notice that the reason for this is that there is a global variable created of type Microsoft.Exchange.Data.Directory.AdminSessionADSettings.
$global:AdminSessionADSettings = [Microsoft.Exchange.Data.Directory.AdminSessionADSettings]::Instance
## Reset the Default Domain
$global:AdminSessionADSettings.ViewEntireForest = $false
You can take advantage of this variable to set the Shell to your likings. Let’s have a look.
$AdminSessionADSettings.ViewEntireForest=$True
If you have multiple domains in your organization, it might be useful to set the scope to the entire forest, for example when running Get-Mailbox you will by default get back the list of mailboxes the shell can retrieve from the domain controller he’s connected to. When setting the scope to the entire forest, you will get a list retrieved by querying a global catalog. The beauty of it all is, that when you want to change something to a particular object, the change will occur against a domain controller in the domain the object belongs to.
To change the scope of the Exchange Management Shell to the entire forest, you need to change the value of the boolean property ViewEntireForest from false to true, as can be seen below:
$AdminSessionADSettings.ViewEntireForest=$True
You will notice that in the title bar tat the scope is set to View Entire Forest.
Not only can I increase the scope to the entire forest, you can focus the scope to one particular Organizational Unit, by setting the value of the property DefaultScope to an organizational unit, like:
$AdminSessionADSettings.DefaultScope=”ProExchange.Global/Employees”
And that’s not all, when looking at the members of this variable, you will notice that you can use the variable to set the shell to use one particular Domain Controller (or a list of) or one (or more) Global Catalogs when using the Shell.
[PS] C:\>$AdminSessionADSettings | gm
TypeName: Microsoft.Exchange.Data.Directory.AdminSessionADSettings
Name MemberType Definition�
—- ———- ———-
ClearPreferredDomainControllers Method System.Void ClearPreferredDomai…
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode() �
GetType Method System.Type GetType() �
get_ConfigurationDomainController Method Microsoft.Exchange.Data.Fqdn ge…
get_DefaultScope Method System.String get_DefaultScope()
get_PreferredDomainControllers Method Microsoft.Exchange.Data.MultiVa…
get_PreferredGlobalCatalog Method Microsoft.Exchange.Data.Fqdn ge…
get_ViewEntireForest Method System.Boolean get_ViewEntireFo…
RemovePreferredDomainController Method System.Void RemovePreferredDoma…
RemovePreferredDomainControllers Method System.Void RemovePreferredDoma…
SetPreferredDomainController Method System.Void SetPreferredDomainC…
SetPreferredDomainControllers Method System.Void SetPreferredDomainC…
set_ConfigurationDomainController Method System.Void set_ConfigurationDo…
set_DefaultScope Method System.Void set_DefaultScope(St…
set_PreferredDomainControllers Method System.Void set_PreferredDomain…
set_PreferredGlobalCatalog Method System.Void set_PreferredGlobal…
set_ViewEntireForest Method System.Void set_ViewEntireFores…
ToString Method System.String ToString() �
ConfigurationDomainController Property Microsoft.Exchange.Data.Fqdn Co…
DefaultScope Property System.String DefaultScope {get…
PreferredDomainControllers Property Microsoft.Exchange.Data.MultiVa…
PreferredGlobalCatalog Property Microsoft.Exchange.Data.Fqdn Pr…
ViewEntireForest Property System.Boolean ViewEntireForest…
That’s it for now,
Feel free to let me know if there is anything you’d like to see covered here!
– Ilse
Ilse Van Criekinge (Exchange MVP, Author Exchange Management Shell: TFM)
1 comment on “Why a variable called AdminSessionADSettings might interest you as Exchange 2007 Admin”
Comments are closed.