Getting group members and group membership.

dallasitguy

Distinguished
Jan 27, 2005
3
0
18,510
Archived from groups: microsoft.public.win2000.active_directory (More info?)

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..
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.active_directory (More info?)

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,
--
Andrei Ungureanu
www.eventid.net
Free Windows event logs reports
http://www.altairtech.ca/evlog/

"DallasITguy" <DallasITguy@discussions.microsoft.com> wrote in message
news:94CCC436-7F66-4483-AD57-3DCA8C4769B8@microsoft.com...
>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..
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.active_directory (More info?)

On Thu, 27 Jan 2005 10:19:02 -0800, "DallasITguy" <DallasITguy@discussions.microsoft.com> wrote:

>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
 

dallasitguy

Distinguished
Jan 27, 2005
3
0
18,510
Archived from groups: microsoft.public.win2000.active_directory (More info?)

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..

"Jerold Schulman" wrote:

> On Thu, 27 Jan 2005 10:19:02 -0800, "DallasITguy" <DallasITguy@discussions.microsoft.com> wrote:
>
> >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
>
 

dallasitguy

Distinguished
Jan 27, 2005
3
0
18,510
Archived from groups: microsoft.public.win2000.active_directory (More info?)

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..