{"id":261,"date":"2014-09-28T15:17:20","date_gmt":"2014-09-28T19:17:20","guid":{"rendered":"http:\/\/adsecurity.org\/?p=261"},"modified":"2014-10-01T20:58:27","modified_gmt":"2014-10-02T00:58:27","slug":"powershell-adsi-and-case-sensitivity","status":"publish","type":"post","link":"https:\/\/adsecurity.org\/?p=261","title":{"rendered":"PowerShell: ADSI and Case Sensitivity"},"content":{"rendered":"<p>In developing a custom PowerShell script which leveraged ADSI, I noticed that the script wasn\u2019t working properly.<\/p>\n<p>Here\u2019s a sample block of the script which uses ADSI to get changes made to ExtensionAttribute11 as part of an Active Directory Convergence test script:<\/p>\n<div class=\"codecolorer-container text vibrant\">\n<table cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"line-numbers\">\n<div>1<br \/>\n2<br \/>\n3<br \/>\n4<\/div>\n<\/td>\n<td>\n<div class=\"text codecolorer\">$ADSITarget = [ADSI]&#8221;LDAP:\/\/$DC&#8221;<br \/>\n$Searcher = New-Object DirectoryServices.DirectorySearcher($ADSITarget,&#8221;(sAMAccountName=$ConvergenceObject)&#8221;)<br \/>\n$ConvergenceObjectData = ($Searcher.FindOne()).properties<br \/>\n$ConvergenceObjectDataValue = (($Searcher.FindOne()).properties).ExtensionAttribute11<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>I usually use Title Case when typing attributes and the script block above was not populating the variable \u201c$ConvergenceObjectDataValue\u201d with any data even though the attribute had data. I realized after enumerating the variable $ConvergenceObjectData that the attribute name was displayed as <strong>extensionattribute11 <\/strong>not <strong>E<\/strong>xtension<strong>A<\/strong>ttribute11.\u00a0 After changing line #1 to line #2, it worked:<\/p>\n<p>Line #1:<br \/>\n$ConvergenceObjectDataValue = (($Searcher.FindOne()).properties).<strong>ExtensionAttribute11<\/strong><\/p>\n<p>Line #2:<br \/>\n$ConvergenceObjectDataValue = (($Searcher.FindOne()).properties).<strong>extensionattribute11<\/strong><\/p>\n<p>So, be careful when using ADSI (or any other API) since it may be case sensitive.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In developing a custom PowerShell script which leveraged ADSI, I noticed that the script wasn\u2019t working properly. Here\u2019s a sample block of the script which uses ADSI to get changes made to ExtensionAttribute11 as part of an Active Directory Convergence test script: 1 2 3 4 $ADSITarget = [ADSI]&#8221;LDAP:\/\/$DC&#8221; $Searcher = New-Object DirectoryServices.DirectorySearcher($ADSITarget,&#8221;(sAMAccountName=$ConvergenceObject)&#8221;) $ConvergenceObjectData = &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/adsecurity.org\/?p=261\">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,2],"tags":[93,575],"class_list":["post-261","post","type-post","status-publish","format-standard","hentry","category-powershell","category-technical-reference","tag-adsi-case-sensitivity","tag-powershell","item-wrap"],"_links":{"self":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/261","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=261"}],"version-history":[{"count":1,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/261\/revisions"}],"predecessor-version":[{"id":262,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/261\/revisions\/262"}],"wp:attachment":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}