List members of a Group

You can retrieve a list of users from a Security or
Distribution Group in domain by using DSget tool – a new tool introduced in
Windows 2003. This tool and other related tools ships with Windows 2003 CD.


Let’s say you need to gather a list of users (+nested groups) from a domain group. This is bit easy. You can use the following command to accomplish the goal:

dsget group “DN_of_group” -members -expand > userlist.txt

The output will be saved in userlist.txt

This is the sample output saved in userlist.txt

“CN=Shan Dallis,OU=Users,DC=test,DC=local”
“CN=Tapihe C Mdwa,OU=Users,DC=test,DC=local”

and so on…



16 thoughts on “List members of a Group”

  1. thats very good, but how do I just have the list of usernames in the txt file rather than all that other crap with it. :)

    Thanks in advance

  2. you could get just teh user names with a simple vb script ..
    ;….
    set args = Wscript.Arguments
    set grp = GetObject(“WinNT://DomainName/” + args(0), group)
    for each usr in grp.members
    wscript.echo usr.name
    next
    ;….
    Then run from the command line
    cscript scriptname.vbs GroupName

    you can modify the vb, to include the info you want, add delimiters, etc. eg. wscript.echo usr.name & ” ” & usr.fullname & ” ” & usr.description

  3. The “net group abc >C:\report.txt” worked great – but what I really need is the list of members in each group and what access level they have. Any ideas on what to query for that?

    Thanks much!

  4. galera eu gostaria de saber, se existe a opção de relacionar todos os grupos de um AD juntos com os membros que esses grupos possuem. valeuuu

  5. string Department = “Billing”;
    DirectorySearcher LdapSearcher = new DirectorySearcher();
    LdapSearcher.PropertiesToLoad.Add(“displayName”);
    LdapSearcher.PropertiesToLoad.Add(“cn”);
    LdapSearcher.PropertiesToLoad.Add(“department”);
    LdapSearcher.PropertiesToLoad.Add(“title”);
    LdapSearcher.PropertiesToLoad.Add(“memberOf”);
    LdapSearcher.Filter = string.Format(“(&(objectClass=user)(department={0}))”, Department);
    SearchResultCollection src = LdapSearcher.FindAll();

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>