Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with query on AD using dsquery and dsget

Status
Not open for further replies.

tekieVB

MIS
Apr 25, 2002
112
US
Probably a quick answer for this one......

I want to use the built in tools for searching AD.

I want to run "dsquery group | dsget group -members | sort?"

Something like that - basically I want to get a list of all groups and it members output "Common Names".

Example:

Domain Administrators
Larry Moe Curly John Lucy Beverly

Backup Operators
Lucy Beverly John

Accounting
Bob Maddison Lynda Carly

Hopefully this is something easy with just a simple batch file?

Regards,
Tekievb
 
here's a potential for you:

ldifde -f c:\export.ldf -l member -r "(objectClass=group)"

kind of messy, but effective. this could be fairly easily done in C# with a nice GUI as well.

~Intruder~
CEH, CISSP, MCSA/MCSE 2000/2003

"The Less You Do, The Less Can Go Wrong"
 
Here is the VBScript code for the same request. Copy everything after CODE: and place it in a txt file but rename it with the .vbs extention. Just change the LDAP path to the group you want.

CODE:
On Error Resume Next

Set objGroup = GetObject _
("LDAP://cn=GroupName,ou=Sales,dc=mydomain,dc=com")
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top