Solved

Export Distribution Groups and members to csv file

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
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 …

830 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