Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

We need a print out of members of all distribution groups by group.

Posted on 2014-09-19
6
Medium Priority
?
415 Views
Last Modified: 2014-09-23
We have an Microsoft Exchange 2013 server.   We need a print out of members of all distribution groups by group.  Is there a powershell command that will export such a listing to a .csv file.
0
Comment
Question by:Dgreenbaum
6 Comments
 
LVL 3

Expert Comment

by:Sean Fitzpatrick
ID: 40333293
You can use Get-ADUser and Export-Csv cmdlets like below:

Get-ADUser -Filter * -SearchBase "ou=Ou,dc=contoso,dc=com" -Properties * | Export-Csv  "c:\somefile.csv"

The parameter "-Filter" is used to specify the query string, "-SearchBase" to specify an Active Directory path to search under and the "-Properties" to specify user's properties you want to export.

Details please go to:
http://technet.microsoft.com/en-us/library/ee617241.aspx

In your case you would be searching by the group that you are looking for, then just change the filter to separate each group into a .csv; or you could broaden your search filter to grab all groups.
0
 
LVL 40

Accepted Solution

by:
Subsun earned 1000 total points
ID: 40333304
Get-ADUser will only give the user information, to get the distribution groups and it's members, run the following script from Exchange Management Shell.
$Groups = Get-DistributionGroup -ResultSize Unlimited
$(ForEach ($group in $Groups){
$Group | Get-DistributionGroupMember -ResultSize Unlimited |
  Select @{N="GroupName";E={$Group.DisplayName}},`
		@{N="User";E={$_.DisplayName}},PrimarySmtpAddress
}) | Export-CSV C:\Group.csv -nti

Open in new window

0
 
LVL 16

Assisted Solution

by:Joshua Grantom
Joshua Grantom earned 1000 total points
ID: 40333315
Boom, Subsun beat me to it.

Except, I would change Export-CSV C:\Group.csv -nti

to

Export-CSV "C:\$Group.csv" -nti

So you have the name of the Distribution Group in the CSV Filename.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 

Author Comment

by:Dgreenbaum
ID: 40333327
Thanks Subsun!   We will test this and report back.
0
 
LVL 3

Expert Comment

by:Sean Fitzpatrick
ID: 40339601
Ah, thanks for the correction subsun!
0
 

Author Closing Comment

by:Dgreenbaum
ID: 40339629
The script worked well.  Thank you all.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you can connect to your internal network or can connect to your router but are not able to connect to the Internet follow these steps in order until the problem is resolved.   1. Right click on the network icon on the task bar and select "Troub…
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…

772 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