Exchange 2013- Need count of DL members alongwith members of nested DL's

This topic contains 4 replies, has 3 voices, and was last updated by  John Mello 10 months, 2 weeks ago.

  • Author
  • #74533



    I am working on the below script to get DL member count:
    $DistributionGroups = Get-DistributionGroup -Resultsize Unlimited
    $DistributionGroups |? {!((Get-DistributionGroupMember -resultsize unlimited $_).count -gt 100)} | Select Name,PrimarySmtpaddress,@{n="Count";e={(Get-DistributionGroupMember -resultsize unlimited $_).count}} | export-csv final.csv

    The above script will give me DL Name and Count if it has more than 100 members in it.

    However the problem is if DL has 50 members and a nested DL( with more than 100 members in it); then I wont be able to get the output.

    I need to have an output that would give me DL Name and count of members (which includes the members of nested DL)

  • #74536

    Olaf Soyk

    Could you please format your code as code here in the forum?

    This Technet Forum thread might be helpful for you:

    Get-DistributionGroupMember Recursive Functionality.

    • #74540


      Thanks Olaf for taking some time out and checking on it.
      I have tried get-adgroupmember in past but if the group has more than 1000 members then it won't give an output. I have used dsget.exe commands to pull out group members details and query members.
      In my case, I have DL's with nested DL's containing more than 1000 members.

    • #74558

      Olaf Soyk

      You could try using Get-ADObject. If I remember right there not such a limit.

  • #74579

    John Mello

    Shashank, I wrote a function for my company a few months that returns the recursive members of a distribution group plus the name of the nest group they were in. Maybe it might help : Get-DistributionGroupMemberRecursive

You must be logged in to reply to this topic.