title: How can I use Regex to pull just the CN from a Distinguished Name with PowerShell
body: <p>I have a bunch of strings that are DN's of groups from AD. I need to pull out the Common Name.
  An example string is "CN=Group Name I Want,OU=Group Container,DC=corp,DC=test,DC=local"</p>
  
  <p>What I am looking for is some PowerShell Code that will pull "Group Name I Want" out of that string and discard the rest. </p>
  
  <p>I can rip of the CN with this</p>
  
  <pre><code>$s = "CN=Group Name I Want,OU=Group Container,DC=corp,DC=test,DC=local"
  $s = $s.Remove(0,3) 
  </code></pre>
  
  <p>But after that, I don't have a good way to rip off everthing starting at ",OU" </p>
  
  <p>I am sure there is some regex that will do this but I need some help figuring it out.</p>