Solved

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

Posted on 2011-09-28
5
698 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
Comment Utility
$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
Comment Utility
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
Comment Utility
Get-DistributionGroup | ForEach {(Get-DistributiongroupMember).Count}
0
 

Author Closing Comment

by:PoorNonProfit
Comment Utility
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
Comment Utility
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now