Export AD Group Members to TXT File

M

Marty

I am trying to find a way to export the members of a group
into a text file. The text file should only contain the
usernames, not the display or anything else.
 
T

Tomasz Onyszko

Marty said:
I am trying to find a way to export the members of a group
into a text file. The text file should only contain the
usernames, not the display or anything else.

This will give you DN of each group member
===
strGroupDN = "CN=Group,OU=GroupOU,DC=domain,DC=local"
Set objGroup = GetObject("LDAP://" & strGroupDN)

arrMemberOf = objGroup.GetEx("member")

WScript.Echo "Members:"
For Each strMember in arrMemberOf
WScript.echo strMember
Next

Set objGroup = Nothing
===

if you want to get their samAccount name You can also do this with a script
==
Set objUser = GetObject("LDAP://" & strMember )
Wscript echo objUser.Get("samAccountName")
Set objGroup = Nothing
==

In such way You can get value all of user's attribute
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top