Solved

Export Distribution Groups and members to csv file

Posted on 2010-09-02
4
2,231 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
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 250 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Installing a printer using group policy preferences is not that hard let’s take a look at it. First lets open up your group policy console and edit the policy you want to add it to. I recommend creating a new policy for each printer makes it a l…
Introduction You may have a need to setup a group of users to allow local administrative access on workstations.  In a domain environment this can easily be achieved with Restricted Groups and Group Policies. This article will demonstrate how to…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now