DN splitting RRS feed

  • Question

  • Hello guys, 

    i was wondering if you can help me out with this. 

    I have a DN that looks like this

    CN=Swenor\, Kyle,OU=Users,OU=Operations,OU=Global Administration,OU=North America,DC=com,DC=com,DC=com,DC=com

    but all I really want is 

    Swenor, Kyle.

    How can I accomplish this?

    Thank you in advance


    Friday, March 31, 2017 6:01 PM


All replies

  • Hi,

     Not possible, DN should not include special characters and CN=Swenor\, Kyle,O 

    and please confirm the CN name exactly. 

    This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing!

    Friday, March 31, 2017 6:06 PM
  • DNs can have special characters and they will be escaped.

    Get the object
    $user = [adsi]"LDAP://$distinguishedname"


    Friday, March 31, 2017 6:25 PM
  • Thank you

    Worked like a charm. 

    Friday, March 31, 2017 6:35 PM
  • You can also use Get-ADPathname.ps1, which is simply a wrapper for the Pathname COM object.

    PS C:\> Get-ADPathname.ps1 "CN=Swenor\, Kyle,OU=Users,OU=Operations,OU=Global Administration,OU=North America,DC=com,DC=com,DC=com,DC=com" -Format Leaf -ValuesOnly -EscapedMode OffEx
    Swenor, Kyle

    -- Bill Stewart [Bill_Stewart]

    Friday, March 31, 2017 7:15 PM