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.
This topic is 14 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
jwelch
Posts: 2
Last visit: Wed Jul 09, 2008 5:48 am

DSQuery script

Post by jwelch »

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
Last visit: Wed Jul 09, 2008 5:48 am

DSQuery script

Post by jwelch »

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
Last visit: Mon Oct 19, 2015 9:21 am

DSQuery script

Post by jhicks »

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
Last visit: Tue Jan 17, 2017 9:26 am

DSQuery script

Post by joel.delatorre »

Adfind can do this.adfind -b "dc=yourDomain,dc=com" -f "objectcategory=person" attr memberof, cn
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

DSQuery script

Post by jhicks »

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
Last visit: Tue Jan 19, 2010 4:01 am

DSQuery script

Post by cooldisks »

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
Last visit: Tue Jan 19, 2010 4:01 am

DSQuery script

Post by cooldisks »

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. ;-)
This topic is 14 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked