DSQuery script

Batch, ASP, JScript, Kixtart, etc.
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.
Locked
User avatar
jwelch
Posts: 2
Joined: Wed Jul 09, 2008 5:44 am

DSQuery script

Post by jwelch » Wed Jul 09, 2008 5:48 am

I need to query AD and find all the active users in our company and find what groups they are in. How do I do this? Is this only a command line query or can I do this from "Active Directory Users and Computers"?

User avatar
jwelch
Posts: 2
Joined: Wed Jul 09, 2008 5:44 am

DSQuery script

Post by jwelch » Wed Jul 09, 2008 5:48 am

I need to query AD and find all the active users in our company and find what groups they are in. How do I do this? Is this only a command line query or can I do this from "Active Directory Users and Computers"?

User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

DSQuery script

Post by jhicks » Thu Jul 10, 2008 4:20 am

Another approach if you have a text list of groups is this http://www.sapien.com/blog/2007/02/19/g ... uerydsget/

User avatar
joel.delatorre
Posts: 83
Joined: Tue Dec 16, 2008 5:51 am

DSQuery script

Post by joel.delatorre » Thu Jul 10, 2008 4:25 am

Adfind can do this.adfind -b "dc=yourDomain,dc=com" -f "objectcategory=person" attr memberof, cn

User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

DSQuery script

Post by jhicks » Thu Jul 10, 2008 4:30 am

Yep. I didn't even begin to mention all the other free tools that could get this done. Ultimately, jwelch, it depends on your comfort level and what you want to do with the information once you have it.

User avatar
cooldisks
Posts: 2
Joined: Tue Jan 19, 2010 4:12 am

DSQuery script

Post by cooldisks » Tue Jan 19, 2010 4:15 am

Here is a script i wrote out to pull the information then i put it into notepad and use Find/Replace to strip out the undersiderable details. Hope it helps.

List users limit to max 2000 user and put out to a text file.
dsquery user -limit 2000 >listuser.txt

List users by Department to a text file:
dsquery user -limit 0 |dsget user -dept -dn >> userlistDept.txt

List Computers in network
dsquery computer -limit 2000 >CPUlist.txt

Hope you enjoy.

Alan Mitchell
cooldisks.com

User avatar
cooldisks
Posts: 2
Joined: Tue Jan 19, 2010 4:12 am

DSQuery script

Post by cooldisks » Tue Jan 19, 2010 5:01 am

Figures lol its the way it goes i didnt even look at the date on it. I do have a useful tool here for others i created a XP version of DSquery scripting for my desktop by going into Windows 2003 and pulling out the following files, i placed them into a folder on my XP box and now i can query against any server without logging into it.

dsprop.dll, dsquery.dll, dsquery.exe, dsrestor.dll, dsrevt.dll, dsrm.exe, dssec.dat, dssec.dll, dssenh.dll, dssite.msc, dsuiext.dll, dsuiwiz.dll.

Since people are still finding their way here someone may use it. ;-)

Locked