title: Convert Distinguished Name to SamAccountName without Get-ADUser
body: <p>My machines have the original build of PowerShell v2.0, so <code>Get-ADUser</code> will not work.  I am trying to convert the <code>manager</code> property from it's <code>distinguishedname</code> to it's <code>SamAccountName</code>.</p>
  
  
  
  <pre class="lang-psh prettyprint-override"><code>$searcher = [adsisearcher]"(samaccountname=$env:USERNAME)"
  $searcher.FindOne().Properties.manager
  </code></pre>
  
  <p>This works perfectly if I had <code>Get-ADUser</code>:</p>
  
  <pre class="lang-psh prettyprint-override"><code>(get-aduser (get-aduser $user -Properties manager).manager).samaccountName
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/20068840/powershell-return-managers-samacountname-for-users">Grabbed get-aduser statement from here..</a></p>