Knowledgebase:
How to extract email addresses from an Active Directory or Google Group
Posted by Blair Benjamin, Last modified by Nathaniel Nelson on 07/13/2022 10:39 AM
Background - Lynn Wallace wanted a list of email addresses (only) from a distribution group in Active Directory / Outlook.  The distribution group is Faculty.  She needed it for import into another program/process such as Survey Monkey or something.  These addresses could be derived by creating a new email in Outlook, putting "Faculty" as the To: field, and then hitting the + next to it to expand the contents.  This was not a suitable solution, however, because the data was not in the format she needed.   To remedy this and extract just the email addresses, run the following command from a command promt:
dsget group "cn=Faculty,cn=Users,dc=ad,dc=pbu,dc=edu" -members | dsget user -email >> faculty.txt
To extract the addresses of all current students (for import into Mailchimp or whatever), use the following command:
dsget group "cn=CurrentStudents,ou=eagle,dc=ad,dc=pbu,dc=edu" -members | dsget user -email >> currentstudents.txt
To extract a list of all alumni employees with names and email addresses:
dsget group "cn=AlumniEmployees,cn=Users,dc=ad,dc=pbu,dc=edu" -members | dsget user -display -email >> alumniemployees.txt
 
dsget group "cn=employees,cn=Users,dc=ad,dc=pbu,dc=edu" -members | dsget user -email >> d:\junk\employees.txt
This command pipes the members into a command to get the email and dump it to a file. 
In the future, the full context name (distinguished name) can be derived by going to AD Users & Computers, open the group/user, click on the Attribute Editor tab, and find the entry for "distinguishedName".
 
To extract addresses from a group that is not in AD but rather in Google only, such as students@cairn.edu, go to groups.google.com (when logged in as an admin to Cairn's Google Apps) > Choose My Groups > Select the organization (cairn.edu) > Click Manage (by the desired group) > Click Export Members at the top.
BB - 3/31/14


Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments: