?
Solved

Export Distribution Groups and members to csv file

Posted on 2010-09-02
4
Medium Priority
?
2,289 Views
Last Modified: 2012-05-10
Hi.  I'd like to export all of our universal distribution groups and corresponding members to a csv file. So one big output for everything to a single file.  Is there a command that can do this?

My active directory is on Win 2003 R2.

Any help would be appreciated - thanks!  
0
Comment
Question by:dbrueckner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 33590801
You can use the following PowerShell command...
Get-DistributionGroupMember -identity "distribution group name" | Export-Csv C:\MyFile.Csv

Also refer to this link..
http://www.ucblogs.net/blogs/exchange/archive/2008/07/03/Exporting-distribution-list-membership-to-Excel.aspx
0
 

Author Comment

by:dbrueckner
ID: 33590847
do you know if there is a way or wild card so that a single command will run through all the distribution groups at once to a single file?  that was what i was looking for.
0
 
LVL 3

Accepted Solution

by:
avalenzuela earned 1000 total points
ID: 33590887
You could use something like this
to get all groups to a Text File..

dsquery group "DC=MyDomain,dc=com" -limit 2000 > MyGroups.txt

Then using that list of groups you do the following..

dsget group 'Each_one_Of_My_groups" -members -expand > FileWithmembers.txt



This is a batch file that I have been using...

------ batch file 1 ------------
 Set Data=Groupmembership.txt

 dsquery group "DC=MyDomain,dc=com"  > MyGroups.txt

 For /F "delims=&" %%i in (MyGroups.txt) do Call GroupUsers.bat %%i %Data%
--------------


---------GroupUsers.bat------------

SET  GR=%1
SET  TO=%2
SET  FL=Temp.txt

REM This command dumps every user for Group %GR% to a file %FL%

        dsget group %GR% -members -expand > %FL%

REM This command send every user on the  last file to a new file %TO%
REM and the appends  the group name to the user name   %%i is the username, %GR% is the group

FOR /F  "delims=^" %%i in (%FL%) do @echo %%i%GR% >> %TO%

---------GroupUsers.bat------------














0
 
LVL 57

Expert Comment

by:Mike Kline
ID: 33591005
See this question I helped with last year

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24328572.html

I used adfind in my example; the vbscript ended up being picked....both should work.  I didn't test Tony's script but he is a top guy and is scripts are solid.

Thanks

Mike
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's recap what we learned from yesterday's Skyport Systems webinar.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question