Categories
Active Directory

Cleaning up AD DN’s

Ok, I often have to extract and attribute from AD that returns objects in a DN format. Then I have to clean it up to only get the CN of the object and i re-create what I do every time so I figured I’d post it here so I don’t forget 🙂

So you have a list of DN’s, here’s how to clean it up.

  1. Paste the list into Excel
  2. Do a search/replace on CN= and replace with blank
  3. Punch this formula into an adjacent cell and expand down, "=LEFT(A1,(FIND(",",A1)-1))". This will return all the characters to the left of the first ","
  4. You now have a list of only the CN’s from the full DN 

I hope this helps 🙂