[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Export Distribution Groups and members to csv file

Posted on 2010-09-02
4
Medium Priority
?
2,315 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

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

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

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
Let's recap what we learned from yesterday's Skyport Systems webinar.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

650 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