Export a list of members from an Active Directory group to a text file

I needed to export a list of all the members in an active directory group today. Here are two methods which work well. The first example uses the net group command. In both examples ‘Group Name’ is the name of the group that you want to export the member list for, and memberlist.txt is the name of the output file.

net group “Group Name” /domain > memberlist.txt

The second example uses dsquery and dsget, which will return the full distinguished names of the user objects that are members of the group. This could be useful if you also need to know which organizational unit the members accounts reside in.

dsquery group -name “Group Name” | dsget group -members > memberlist.txt

17 Responses to Export a list of members from an Active Directory group to a text file

  1. keith Rosenberg says:

    So how do I get a list of all groups and their members?

  2. Paul says:

    are running this script in this in cmd?

  3. emnavarro02 says:

    Cool. This save some time. Thnx😉

  4. Kitaab says:

    Thanks It was useful

  5. David says:

    This just saved me a ton of time. Thank you!

  6. Jonathan Rey says:

    Great! simple script. Best solution

  7. Worked great for me. Thank you

  8. Kaihan Arian says:

    Hi all; thanks it is too useful for me but i want know how i can export member of users with its descriptions so please help me …

  9. andrea says:

    dsquery group -name “Group Name” | dsget group -members > memberlist.txt return a error….
    ..

    dsget failed:’Target object for this command’ is missing.

  10. Tony Trunkfield says:

    Great script – and works fast.

  11. sachin says:

    this command cant extract if the group has space between eg. sec audit team

  12. Subhankara Nayak says:

    hi
    from this script we can only know the member name or logon name.
    can we get name with the mail id as well.??

  13. raudan says:

    thanks:)
    it works:)😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: