look at AD group and return display name
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
look at AD group and return display name
i have a script (not written by me) for which I can enter an AD group name and it writes the display name of all members to a text file. I would also like to add the username next to the display name but can't figure it out. here is what I have:'This script will export the list of members of a Group.'Input Variable for AD Group set by user running scriptGroupname = InputBox("Enter Group Name such as CLAS0Users")'Sets AD path to GroupsSet objGroup = GetObject("LDAP://" & "CN=" & Groupname & ",OU=Groups,OU=Las Vegas,OU=CCI,DC=CORP,DC=COX,DC=COM")'Creates Output Text File and HeaderSet objFS = CreateObject("Scripting.FileSystemObject")Set objNewGroup = objFS.CreateTextFile("GroupListing " & groupname & ".txt")objNewGroup.WriteLine "Members of " & GroupnameMemberOf = objGroup.GetEx("member")For Each member in MemberOfSet objUser = GetObject("LDAP://" & member)'Uncomment next line if debugging required'on Error Resume Next objNewGroup.WriteLine objUser.Get ("name")Next Wscript.echo "Script is done"any help would be appreciated.Z
look at AD group and return display name
The usename is the sAMAccountname. objNewGroup.WriteLine objUser.Get ("name") & " " & objUser.Get("sAMAccountName")Is that what you're looking for?
look at AD group and return display name
How do I use this to grab members of all groups in a particular OU, rather than going one group at a time?
Thanks in advance.
Thanks in advance.
look at AD group and return display name
GEt teh OU using LDAP tehn enumerte all of it's objects and apply teh above code to each object that is a group.
You could also filter for "objectClass='group'"
The above example would be modified like this for teh OU:
jvierra2007-05-18 15:03:56
You could also filter for "objectClass='group'"
The above example would be modified like this for teh OU:
Code: Select all
Set objGroup = GetObject(LDAP://"OU=ouName,OU=parentOUNames,DC=CORP,DC=COX,DC=COM")
jvierra2007-05-18 15:03:56
look at AD group and return display name
Thanks much for the response, but I'm getting stuck. It keeps erring the on line *memberof - objgroup.getex("member")*. I'm not sure what to fix, as I'm pretty new to the world of scripting. Any help is appreciated. Here's the modified script from what was previously posted.
Set objGroup = GetObject("LDAP://ou=ou1,OU=Groups,DC=domain,DC=COM")
'Creates Output Text File and HeaderSet objFS = CreateObject("Scripting.FileSystemObject")Set objNewGroup = objFS.CreateTextFile("Grouplist.csv")objNewGroup.WriteLine "Members of " & Groupname
MemberOf = objGroup.GetEx("member")For Each member in MemberOfSet objUser = GetObject("LDAP://" & member)'Uncomment next line if debugging required'on Error Resume Next objNewGroup.WriteLine objUser.Get ("name")
Next Wscript.echo "Script is done"
Set objGroup = GetObject("LDAP://ou=ou1,OU=Groups,DC=domain,DC=COM")
'Creates Output Text File and HeaderSet objFS = CreateObject("Scripting.FileSystemObject")Set objNewGroup = objFS.CreateTextFile("Grouplist.csv")objNewGroup.WriteLine "Members of " & Groupname
MemberOf = objGroup.GetEx("member")For Each member in MemberOfSet objUser = GetObject("LDAP://" & member)'Uncomment next line if debugging required'on Error Resume Next objNewGroup.WriteLine objUser.Get ("name")
Next Wscript.echo "Script is done"