Export a list of members from an Active Directory group to a text file
January 6, 2012 20 Comments
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
So how do I get a list of all groups and their members?
Hi Keith,
Sorry for the late reply. This script seems to do the job:
http://gallery.technet.microsoft.com/scriptcenter/a2d6475e-50e6-4367-9aa4-c19a60674157
are running this script in this in cmd?
Yes, use cscript to invoke the script
Cool. This save some time. Thnx 😉
Thanks It was useful
This just saved me a ton of time. Thank you!
Great! simple script. Best solution
Worked great for me. Thank you
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 …
dsquery group -name “Group Name” | dsget group -members > memberlist.txt return a error….
..
dsget failed:’Target object for this command’ is missing.
Great script – and works fast.
this command cant extract if the group has space between eg. sec audit team
You need to put the group name in quotes e.g. “security team”
hi i want get the DL name , own of the DL and DL users list …. Using in cmd …. output should in text file..
hi
from this script we can only know the member name or logon name.
can we get name with the mail id as well.??
thanks 🙂
it works 🙂 😉
Where does the txt file reside once the script has run?
In the folder where you ran the command from, or alternatively you could specify a path such as c:\memberlist.txt
Thank you very much. This saved my lot of time.