{"id":105,"date":"2014-06-24T15:17:06","date_gmt":"2014-06-24T19:17:06","guid":{"rendered":"http:\/\/blog.metcorp.org\/?p=105"},"modified":"2014-06-09T21:52:53","modified_gmt":"2014-06-10T01:52:53","slug":"powershell-using-a-hashtable-to-identify-active-directory-schema-exchange-version","status":"publish","type":"post","link":"https:\/\/adsecurity.org\/?p=105","title":{"rendered":"PowerShell: Using a HashTable to Identify Active Directory Schema &#038; Exchange Version"},"content":{"rendered":"<p>It&#8217;s easy to get the Active Directory schema version as well as the installed Exchange (schema) version by using the Active Directory PowerShell cmdlet, Get-ADObject. This script leverages a built-out HashTable to perform a lookup against the version numbers.<\/p>\n<div dir=\"ltr\"><\/div>\n<p><code><br \/>\n###################################<br \/>\n# Create Schema Version Hashtable # 20140606-14<br \/>\n###################################<br \/>\nWrite-Verbose \"Create Schema Version HashTable `r \"<br \/>\n$SchemaVersionTable =<br \/>\n@{<br \/>\n\"13\" = \"Windows 2000 Active Directory Schema\" ;<br \/>\n\"30\" = \"Windows 2003 Active Directory Schema\";<br \/>\n\"31\" = \"Windows 2003 R2 Active Directory Schema\" ;<br \/>\n\"44\" = \"Windows 2008 Active Directory Schema\" ;<br \/>\n\"47\" = \"Windows 2008 R2 Active Directory Schema\" ;<br \/>\n\"51\" = \"Windows Server 8 BETA Active Directory Schema\" ;<br \/>\n\"56\" = \"Windows 2012 Active Directory Schema\" ;<br \/>\n\"69\" = \"Windows 2012 R2 Active Directory Schema \" ;<br \/>\n\"4397\" = \"Exchange 2000 RTM Schema\" ;<br \/>\n\"4406\" = \"Exchange 2000 SP3 Schema\" ;<br \/>\n\"6870\" = \"Exchange 2003 RTM Schema\" ;<br \/>\n\"6936\" = \"Exchange 2003 SP3 Schema\" ;<br \/>\n\"10637\" = \"Exchange 2007 RTM Schema\" ;<br \/>\n\"11116\" = \"Exchange 2007 RTM Schema\" ;<br \/>\n\"14622\" = \"Exchange 2007 SP2 &amp; Exchange 2010 RTM Schema\" ;<br \/>\n\"14625\" = \"Exchange 2007 SP3\" ;<br \/>\n\"14726\" = \"Exchange 2010 SP1 Schema\" ;<br \/>\n\"14732\" = \"Exchange 2010 SP2 Schema\" ;<br \/>\n\"14734\" = \"Exchange 2010 SP3 Schema\" ;<br \/>\n\"15137\" = \"Exchange 2013 RTM Schema\" ;<br \/>\n\"15254\" = \"Exchange 2013 CU1 Schema\" ;<br \/>\n\"15281\" = \"Exchange 2013 CU2 Schema\" ;<br \/>\n\"15283\" = \"Exchange 2013 CU3 Schema\" ;<br \/>\n\"15292\" = \"Exchange 2013 SP1 Schema\" ;<br \/>\n\"15300\" = \"Exchange 2013 CU5 Schema\" <\/code><\/p>\n<p>}<br \/>\n################################<br \/>\n# Get AD Schema Version Number # 20111029-14<br \/>\n################################<br \/>\nImport-Module ActiveDirectory<br \/>\nWrite-Output &#8220;Checking Schema version on the PDC Emulator ($ADDomainPDCEmulator) `r &#8221;<br \/>\n$ADSchemaConfigurationDistinguishedName = (Get-ADRootDSE).schemaNamingContext<br \/>\n$ADSchemaVersion = (Get-ADObject $ADSchemaConfigurationDistinguishedName -Property objectVersion).objectVersion<br \/>\n$ADSchemaVersionName = $SchemaVersionTable.Get_Item(&#8220;$ADSchemaVersion&#8221;)<br \/>\nWrite-Output &#8220;The current AD Schema Version is $ADSchemaVersion which is $ADSchemaVersionName `r &#8221;<br \/>\n######################################<br \/>\n# Get Exchange Schema Version Number #<br \/>\n######################################<br \/>\nWrite-Output &#8220;Checking Exchange Schema version `r &#8221;<br \/>\n$ExchangeSchemaConfigurationDistinguishedName = &#8216;cn=ms-exch-schema-version-pt,&#8217; + $ADSchemaConfigurationDistinguishedName<br \/>\n$ExchangeSchemaVersion = (Get-ADObject $ExchangeSchemaConfigurationDistinguishedName -Property rangeUpper).rangeUpper<br \/>\n$ExchangeSchemaVersionName = $SchemaVersionTable.Get_Item(&#8220;$ExchangeSchemaVersion&#8221;)<br \/>\nWrite-Output &#8220;The current Exchange Schema Version is $ExchangeSchemaVersion which is $ExchangeSchemaVersionName `r &#8220;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s easy to get the Active Directory schema version as well as the installed Exchange (schema) version by using the Active Directory PowerShell cmdlet, Get-ADObject. This script leverages a built-out HashTable to perform a lookup against the version numbers. ################################### # Create Schema Version Hashtable # 20140606-14 ################################### Write-Verbose &#8220;Create Schema Version HashTable `r &#8221; &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/adsecurity.org\/?p=105\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[34,35,36,37,575,22],"class_list":["post-105","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-adschema","tag-exchangeschema","tag-get-adobject","tag-get-adrootdse","tag-powershell","tag-powershellcode","item-wrap"],"_links":{"self":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=105"}],"version-history":[{"count":1,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/105\/revisions"}],"predecessor-version":[{"id":106,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/105\/revisions\/106"}],"wp:attachment":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}