Solved

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

Posted on 2011-09-28
5
699 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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Read this checklist to learn more about the 15 things you should never include in an email signature.
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
To show how to generate a certificate request 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 Servers >> Certificates…

777 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