Solved

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

Posted on 2011-09-28
5
704 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
how to add IIS SMTP to handle application/Scanner relays into office 365.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

728 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