Discussion:
DSGET & DSQUERY Problem
(too old to reply)
w***@gmail.com
2006-01-27 10:35:25 UTC
Permalink
i am trying to get a simple spreedsheet detailing our entire AD group
membership, so i used this code in acommand prompt:

dsquery group -name * - limit 1000 | dsget group -members >
C:\result.csv

this works great, and lists all the users name - but they don't have
titles. so it's grouping users into their respective groups, but i
can't tell what the group is called....

does anyone know of a way around this.

thanks for the help

Jason
Jerold Schulman
2006-01-27 13:40:27 UTC
Permalink
Post by w***@gmail.com
i am trying to get a simple spreedsheet detailing our entire AD group
dsquery group -name * - limit 1000 | dsget group -members >
C:\result.csv
this works great, and lists all the users name - but they don't have
titles. so it's grouping users into their respective groups, but i
can't tell what the group is called....
does anyone know of a way around this.
thanks for the help
Jason
If you don't want to script it, just type:
for /f "Tokens=*" %a in ('dsquery group -limit 0') do dsget group %a -members

or create a GiveMeMyGroupMembership.bat file that contains:

@echo off
setlocal ENABLEDELAYEDEXPANSION
for /f "Tokens=*" %%a in ('dsquery group -limit 0') do (
for /f "Tokens=*" %%b in ('dsget group %%a -members') do (
@echo %%a;%%b
)
)
endlocal

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
w***@gmail.com
2006-01-27 14:37:02 UTC
Permalink
Just what was needed - worked a treat - thanks

Jason
w***@gmail.com
2006-01-27 15:02:27 UTC
Permalink
just had another thought - is there a way i can get the code (not the
batch file one) to output to a single csv file? - i tried putting ">
{filename}" at the end but that didn't seem to work.

Any ideas?

jason
w***@gmail.com
2006-01-27 15:05:51 UTC
Permalink
Post by w***@gmail.com
just had another thought - is there a way i can get the code (not the
batch file one) to output to a single csv file? - i tried putting ">
{filename}" at the end but that didn't seem to work.
Any ideas?
jason
Is there also a way to query a particular OU rather than the directory?

Thanks

Jason
Paul Williams [MVP]
2006-01-30 06:54:34 UTC
Permalink
Use the DN of the base instead of domainroot, e.g.

dsquery group ou=test,dc=test-lab,dc=com
--
Paul Williams
Microsoft MVP - Windows Server - Directory Services
http://www.msresource.net | http://forums.msresource.net
Continue reading on narkive:
Loading...