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

x
?
Solved

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

Posted on 2011-09-28
5
Medium Priority
?
711 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 2000 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
This video discusses moving either the default database or any database to a new volume.
Suggested Courses

971 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