Link to home
Start Free TrialLog in
Avatar of sdonaldson07
sdonaldson07

asked on

GetObject special characters

I am trying to get a list of Distribution List members from AD. I have a script that will pull the members, but I ran into an issue with the name of a specific DL. The name has spaces and commas in it, which is causing the script to freak out. I have tried:

Set objGroup = GetObject("LDAP://CN=First Last, First Last, First Last,OU=NAME,OU=All Users,DC=DOMAIN,DC=COM")

Open in new window


Set objGroup = GetObject('"LDAP://CN=First Last, First Last, First Last,OU=NAME,OU=All Users,DC=DOMAIN,DC=COM"')

Open in new window



Set strOUContainter = "CN=First Last, First Last, First Last,OU=NAME"
Set objGroup = GetObject("LDAP://" & strOUContainer & "," & "OU=All Users,DC=DOMAIN,DC=COM")

Open in new window


Set strOUContainter = """CN=First Last, First Last, First Last,OU=NAME"""
Set objGroup = GetObject("LDAP://" & strOUContainer & "," & "OU=All Users,DC=DOMAIN,DC=COM")

Open in new window


I'm not sure how to get the script to read the name of the DL without freaking out over the commas. Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of CitizenRon
CitizenRon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sdonaldson07
sdonaldson07

ASKER

CitizzenRon:

I tried to escape the commas like you suggested and got the following error message:
Microsoft VBScript runtime error: Object required: '[string: "CN=First Last\, Fir"]'

The error message did not finish the second person's first name.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes I am editing the names in my example. I made sure to only escape the characters separating the names, not the ones separating the object. I have tried setting up the CN as a variable and inserting it into the GetObject and I have also tried keeping the names in the GetObject and escaping the commas there. Neither method worked for me.
Closing question.