Count number of users in distribution group

Hi,

I need to find all distribution groups that have more than 50 recipient. I tried with this in ems:

$grupe = Get-DistributionGroup
$grupe | Where-Object { (Get-DistributionGroupMember -Identity $_.Name).Count -gt 50 }

And it is working, but if I have group in group it only count 1 and not member in child group. Example:

Group01@test.com

For group01 number is 4, but i need total number of recipinet.


  • Edited by rajco Friday, December 09, 2011 10:01 AM
December 9th, 2011 1:00pm

Use recursion - http://www.ericwoodford.com/node/290
Free Windows Admin Tool Kit Click here and download it now
December 9th, 2011 3:18pm

This function is working, but only for one concrete group. I cannot pipe all groups.
function Get-DLMembersRecurse ($DL) {
         $memlist = @()
         $mems = Get-DistributionGroupMember $dl -ResultSize unlimited
         foreach ($m in $mems) {
                 if ($m.recipienttype -match "group") {          
                        Get-dlmembersRecurse $m.identity
                 } else {
                         if (($memlist -match $m).count -eq 0) {$memlist += $m           }
                 }       
        }
         return $memlist
 }

I use:
(Get-DLMembersRecurse group01).count 
Now need to count all groups on exchange.  
  • Edited by rajco Tuesday, December 13, 2011 9:33 AM
December 13th, 2011 12:32pm

$grupe | Where-Object { (Get-DLMembersRecurse $_.Name).count  -gt 50 }
  • Marked as answer by rajco Tuesday, December 13, 2011 10:47 AM
Free Windows Admin Tool Kit Click here and download it now
December 13th, 2011 1:12pm

Kazun, sorry for stupid question :) I tried this before last posting, but with error in typing and I have some error with identity. Thank you!
  • Edited by rajco Tuesday, December 13, 2011 10:59 AM
December 13th, 2011 1:55pm

Pair was needing this information exported reports of distribution lists and found a very good script in this link: http://justaucguy.wordpress.com/2013/03/01/recursive-distribution-list-script/
Free Windows Admin Tool Kit Click here and download it now
February 28th, 2014 3:18pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics