DL membership

Roger Roger 4,956 Reputation points
2023-03-23T22:10:52.4466667+00:00

Hi All

i have a DL and i want to know this DL is member of any other DLs. i have used the below syntax but i am not getting output.

$DLName = "dl1@contoso.com"

$DistributionGroups= Get-DistributionGroup -ResultSize Unlimited | where { (Get-DistributionGroupMember $.Name | foreach {$.PrimarySmtpAddress}) -contains "$DLName"}

$DistributionGroups

Microsoft Exchange Online
Exchange Server
Exchange Server
A family of Microsoft client/server messaging and collaboration software.
1,085 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,195 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,359 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
1,896 questions
0 comments No comments
{count} votes

Accepted answer
  1. Xuyan Ding - MSFT 7,561 Reputation points
    2023-03-24T09:09:17.3366667+00:00

    Hi @Roger Roger,

    Please add echo output, the full command is as follows:

    $DLName = ”dl1@contoso.com"
    $DistributionGroups= Get-DistributionGroup -ResultSize Unlimited | where { (Get-DistributionGroupMember $_.Name | foreach {$_.PrimarySmtpAddress}) -contains "$DLName"}
    echo $DistributionGroups
    

    MicrosoftTeams-image (66)


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Vasil Michev 95,671 Reputation points MVP
    2023-03-24T08:14:37.6333333+00:00

    Use this instead:

    $dl = Get-DistributionGroup USG

    $DistributionGroups = Get-Recipient -Filter "Members -eq '$($dl.DistinguishedName)'"

    $DistributionGroups

    0 comments No comments