Getting group members and group membership.

G

Guest

I am needing to pull a list of users that are in a group. I also need to
pull what groups those members are apart of. I can pull this information as
seperate data with dsget but I need to pull options -display and -memberof.
These are in different parts of the command and it fails. What I am trying
to get out of the dsget is the results of:

user1 group1
group2

user2 group1
group2
group3



Thanks..
 
A

Andrei Ungureanu

probably you can do that using a vbscript.
Search on Technet for some scripts and adapt them to your needs.
(search for a script that is listing the group members and for the other one
that is listing from what groups a user is part of).

br,
 
J

Jerold Schulman

I am needing to pull a list of users that are in a group. I also need to
pull what groups those members are apart of. I can pull this information as
seperate data with dsget but I need to pull options -display and -memberof.
These are in different parts of the command and it fails. What I am trying
to get out of the dsget is the results of:

user1 group1
group2

user2 group1
group2
group3



Thanks..


See tip 7225 in the 'Tips & Tricks' at http://www.jsiinc.com for a sample.
See tip 7409
See tip 8875.



Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
 
G

Guest

Thanks all for the info. I'm not a huge programming guy so vb would be a
chore for me. I can do average scripting through dos and the for command.
I'll look at these three articles and see how I can use them.

Thanks for your time and responses..
 
G

Guest

Here's what I came up with that gave me the results. Two ways of getting it.
One is a flat file and the other is an individual file of each group.

This uses the $ as a delimiter for importing into excel.
for /f "tokens=*" %%u in ('dsget group %1 -members') do for /f "tokens=*"
%%b in ('dsget user %%u -memberof -expand -c') do @echo %%u$%%b >> %1.txt

This pipes to a .txt file and then reads the groups.
dsquery group -name %1 > groups.txt
for /f "tokens=1 delims= " %%i in (groups.txt) do dsget group %%i -members >
%%i.txt

Hope this helps someone that reads this..
 

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