{"id":564,"date":"2008-08-05T12:26:39","date_gmt":"2008-08-05T20:26:39","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=564"},"modified":"2008-08-05T12:26:39","modified_gmt":"2008-08-05T20:26:39","slug":"why-a-variable-called-adminsessionadsettings-might-interest-you-as-exchange-2007-admin","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2008\/08\/05\/why-a-variable-called-adminsessionadsettings-might-interest-you-as-exchange-2007-admin\/","title":{"rendered":"Why a variable called AdminSessionADSettings might interest you as Exchange 2007 Admin"},"content":{"rendered":"<p>I must admit, I love Exchange, and the first look\u00a0I 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 \ud83d\ude42<\/p>\n<p>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 ;-))<\/p>\n<p><strong>$AdminSessionAdSettings<\/strong><\/p>\n<p>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&#8217;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\u00a0created\u00a0of type Microsoft.Exchange.Data.Directory.AdminSessionADSettings.<\/p>\n<p><em>$global:AdminSessionADSettings = [Microsoft.Exchange.Data.Directory.AdminSessionADSettings]::Instance<br \/>\n## Reset the Default Domain<br \/>\n$global:AdminSessionADSettings.ViewEntireForest = $false<br \/>\n<\/em><\/p>\n<p>You can take advantage of this variable to set the Shell to your likings. Let&#8217;s have a look.<\/p>\n<p><strong>$AdminSessionADSettings.ViewEntireForest=$True<\/strong><\/p>\n<p>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&#8217;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.<\/p>\n<p>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:<\/p>\n<p><em>$AdminSessionADSettings.ViewEntireForest=$True<\/em><\/p>\n<p>You will notice that in the title bar tat the scope is set to View Entire Forest.<\/p>\n<p>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 <em>DefaultScope<\/em> to an organizational unit, like:<\/p>\n<p><em>$AdminSessionADSettings.DefaultScope=&#8221;ProExchange.Global\/Employees&#8221;<\/em><\/p>\n<p>And that&#8217;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.<\/p>\n<p>[<em>PS] C:\\&gt;$AdminSessionADSettings | gm<\/em><br \/>\n<em> TypeName: Microsoft.Exchange.Data.Directory.AdminSessionADSettings<\/em><\/p>\n<p><em>Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0MemberType Definition\ufffd<br \/>\n&#8212;-\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- <\/em><\/p>\n<p><em>ClearPreferredDomainControllers\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Method\u00a0\u00a0\u00a0\u00a0 System.Void ClearPreferredDomai&#8230;<br \/>\nEquals\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Boolean Equals(Object obj)<br \/>\nGetHashCode\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Int32 GetHashCode()\u00a0\u00a0\u00a0\u00a0\u00a0\ufffd<br \/>\nGetType\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Type GetType()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\ufffd<br \/>\nget_ConfigurationDomainController\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 Microsoft.Exchange.Data.Fqdn ge&#8230;<br \/>\nget_DefaultScope\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.String get_DefaultScope()<br \/>\nget_PreferredDomainControllers\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Method\u00a0\u00a0\u00a0\u00a0 Microsoft.Exchange.Data.MultiVa&#8230;<br \/>\nget_PreferredGlobalCatalog\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 Microsoft.Exchange.Data.Fqdn ge&#8230;<br \/>\nget_ViewEntireForest\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Boolean get_ViewEntireFo&#8230;<br \/>\nRemovePreferredDomainController\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Void RemovePreferredDoma&#8230;<br \/>\nRemovePreferredDomainControllers\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Void RemovePreferredDoma&#8230;<br \/>\nSetPreferredDomainController\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Method\u00a0\u00a0\u00a0\u00a0 System.Void SetPreferredDomainC&#8230;<br \/>\nSetPreferredDomainControllers\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Void SetPreferredDomainC&#8230;<br \/>\nset_ConfigurationDomainController\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Void set_ConfigurationDo&#8230;<br \/>\nset_DefaultScope\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Void set_DefaultScope(St&#8230;<br \/>\nset_PreferredDomainControllers\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Void set_PreferredDomain&#8230;<br \/>\nset_PreferredGlobalCatalog\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Void set_PreferredGlobal&#8230;<br \/>\nset_ViewEntireForest\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.Void set_ViewEntireFores&#8230;<br \/>\nToString\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method\u00a0\u00a0\u00a0\u00a0 System.String ToString()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\ufffd<br \/>\nConfigurationDomainController\u00a0\u00a0\u00a0\u00a0 Property\u00a0\u00a0 Microsoft.Exchange.Data.Fqdn Co&#8230;<br \/>\nDefaultScope\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Property\u00a0\u00a0 System.String DefaultScope {get&#8230;<br \/>\nPreferredDomainControllers\u00a0\u00a0\u00a0\u00a0 Property\u00a0\u00a0 Microsoft.Exchange.Data.MultiVa&#8230;<br \/>\nPreferredGlobalCatalog\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Property\u00a0\u00a0 Microsoft.Exchange.Data.Fqdn Pr&#8230;<br \/>\nViewEntireForest\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Property\u00a0\u00a0 System.Boolean ViewEntireForest&#8230;<br \/>\n<\/em>That&#8217;s it for now,<\/p>\n<p>Feel free to let me know if there is anything you&#8217;d like to see covered here!<\/p>\n<p>&#8211; Ilse<\/p>\n<p>Ilse Van Criekinge (Exchange MVP, Author <a href=\"http:\/\/www.sapienpress.com\/exchange.asp\" target=\"_blank\">Exchange Management Shell: TFM<\/a>)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 \ud83d\ude42<\/p>\n<p>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 powershells addicts have a look at this great messaging product Exchange is now, (and have to admit, always has been ;-))<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[160,25],"tags":[88,998,28],"class_list":["post-564","post","type-post","status-publish","format-standard","hentry","category-exchange-management-shell","category-windows-powershell","tag-exchange-2007","tag-exchange-management-shell","tag-powershell"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=564"}],"version-history":[{"count":5,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/564\/revisions"}],"predecessor-version":[{"id":569,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/564\/revisions\/569"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}