Solved

Exchange 2010 SP1 - Export the number of users in a distribution list

Posted on 2011-09-28
5
701 Views
Last Modified: 2012-05-12
I need to export the number of users in each dist list to txt or csv.

I located to cmdlet to export the members of a dist list (Get-DistributionGroupMember "Dist name" > c:\path ) but is there a cmdlet I can run to view how many users are in each dist list ?

We have a new company policy that I need to restrict access to dist lists with more than 25 users but we have over 300 dist lists...

Is there a cmdlet I can run that will tell me which groups have more than 25 people ?

Thanks
0
Comment
Question by:PoorNonProfit
5 Comments
 
LVL 49

Accepted Solution

by:
Akhater earned 500 total points
ID: 36812705
$all = @()
$grp = Get-DistributionGroup -ResultSize unlimited
$grp | % {
   $n = (Get-DistributionGroupMember $_).count
   if ($n -gt "25") {
       $out = new-object psobject  
   
       $out | add-member noteproperty GroupName $_
       $out | add-member noteproperty MemberCount $n
     
       $all += $out
   }
}

$all | Sort-Object membercount -Descending | export-csv c:\groupcount.csv
0
 
LVL 24

Expert Comment

by:Rajith Enchiparambil
ID: 36813599
get-distributiongroupmamber "groupname" | measure-object gives the number of users for that group. If you have more, get all groups in a variable and use a for loop to loop through.
0
 
LVL 9

Expert Comment

by:MNH1966
ID: 36813785
Get-DistributionGroup | ForEach {(Get-DistributiongroupMember).Count}
0
 

Author Closing Comment

by:PoorNonProfit
ID: 36817041
Thank you for your help..

Akhater, your solution was exactly what I needed.  Thank you....

One thing that does not appear to work is the -ResultSize unlimited. When I run this PS1 I get the:

"WARNING: By default, only the first 1000 items are returned"

Do I need to move the -Resultsize swithc to another location ?
0
 
LVL 49

Expert Comment

by:Akhater
ID: 36817905
can you run  Get-DistributionGroup -ResultSize unlimited alone ? does it give back the same warning ?

is it possible that you have a group with more than 1000 members ? my guess is that it is the Get-DistributionGroupMember part returning the warning
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 step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
In-place Upgrading Dirsync to Azure AD Connect
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

838 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