List Parent Distribution Groups that Nested Distribution Groups Might be Members Of


  • Hi,

    We have a series of typical regular universal distribution groups. We also have a large number of dynamic distribution groups. The dynamic distribution groups have been placed / nested in the universal distribution groups

    We need to be able to determine which static groups a dynamic group is a member of

    We're not looking to list the members of a group, or to recursively list members of a group and the members of a group nested within each group. Instead, we want to be able to determine, for example, which universal distribution groups the dynamic distribution group "MyDynGroup" belongs to

    We have tried:

    $groups = Get-DistributionGroup

    $groups | where-object { ( Get-DistributionGroupMember $_ | where-object { $_.Name -eq “MyDynGroup”}) }

    we have also tried commands along the line of:

    Get-DistributionGroup |  Get-DistributionGroupMember | where { $_.Name -eq "MyDynGroup"} | select name

    No joy unfortunately

    Any help would be greatly appreciated


    Tuesday, January 24, 2017 4:38 PM

All replies

  • This script will return all DLs that have a nested DDG in them:

    $DLs = Get-DistributionGroup
    ForEach ($Group in $DLs) {
        $DDLs  = $null
        $DDLs = Get-DistributionGroupMember $Group | ?{$_.RecipientType -eq "DynamicDistributionGroup"}
        IF ($DDLs -ne $null) {
            Write-Host "[$Group.Name] contains:"
            Write-Host $DDls

    If this post helps to resolve your issue, please click the <Propose as Answer>. If you find it helpful , mark it as helpful by clicking on <Vote as Helpful> button at the top of this message. By marking a post as Answered, or Helpful you help others find the answer faster. Microsoft Infrastructure Architect, MCSE: M, MCTIP, Microsoft Exchange MVP

    • Proposed as answer by Jason Sherry Tuesday, January 24, 2017 6:55 PM
    Tuesday, January 24, 2017 6:55 PM
  • Thanks, but we're not looking to get a list of members, or of nested dynamic groups. Instead, what we're looking to do is discover which groups a certain dynamic group is nested within

    We know how to pull a list of the members of a group, and all the dynamic groups that are listed within that group. However, what we are trying to do is, prior to deleting a dynamic group, do a search and discover which groups it has been nested within.

    So there could be 20 universal distribution groups that a certain dynamic distribution groups has been nested within, and we want to pull that list (so return a result that essentially tells us "the dynamic group dyngroup is nested inside the following 20 distribution groups:..." followed by a list of all the universal distribution groups that dynamic group is a member of


    Wednesday, January 25, 2017 8:44 AM
  • Hi  LabBunch,

    Try the following command:

    ForEach ($Group in Get-DistributionGroup) 
    ForEach ($Member in Get-DistributionGroupMember -identity $Group | Where { $_.Name –eq "MyDynGroup" })    

    I have tested in my lab, it works as expected:

    Best Regards,

    Niko Cheng
    TechNet Community Support

    Please remember to mark the replies as answers.
    If you have feedback for TechNet Subscriber Support, contact

    Tuesday, February 7, 2017 10:11 AM