title: Parsing the canonical name out of a distinguished name
body: <p>I have a small script that I can search people by their different properties and pull certain info. I pull the <code>Memberof</code> property, but it is kind of ugly with the full path. All I want is the canonical name.</p>
  
  <p>I thought that I could pipe <code>Memberof</code> to <code>Where-Object</code> and match from <code>cn</code> to the first <code>,</code>:</p>
  
  <pre><code>select Name, EmailAddress, SAMAccountName, SN, Memberof |
    Where-Object -FilterScript:{$_.Memberof -match "cn*,"} | fl
  </code></pre>
  
  <p>Is this more complicated than I am thinking, or am I overlooking something? Any help would be nice.</p>