query on mail contacts/mail users

Rising Flight 4,596 Reputation points
2024-11-06T22:30:59.5466667+00:00

Hi All,

I am working in an Exchange 2016 hybrid environment. I have mail contacts and mail users in Exchange 2016, as well as mail contacts, mail users, and external users in Exchange Online. I also have distribution lists (DLs) in both Exchange On-Premises and Exchange Online.

Is it possible to identify the distribution lists, both on-premises and online, in which these mail contacts, mail users, and external users are members?

Please guide me.

Microsoft Exchange Online
Exchange Server
Exchange Server
A family of Microsoft client/server messaging and collaboration software.
1,337 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,578 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,669 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.
2,135 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Alex Zhang-MSFT 1,675 Reputation points Microsoft Vendor
    2024-11-07T02:36:34.3133333+00:00

    Hello, @Rising Flight,

    Welcome to the Microsoft Q&A platform!

    Based on your requirements, I can help guide you through identifying the distribution lists (DLs) in which your mail contacts, mail users, and external users are members in both Exchange On-Premises and Exchange Online environments.

    1. Connect to Exchange On-Premises: Open the Exchange Management Shell on your Exchange 2016 server and run the following command to get the distribution groups and their members.
    Get-DistributionGroup | ForEach-Object { Get-DistributionGroupMember $_.Identity | Select-Object @{Name="GroupName";Expression={$_.Identity}}, Name, RecipientType }
    
    1. Connect to Exchange Online: Open the Windows PowerShell and connect to Exchange Online using the following commands.
    $UserCredential = Get-Credential
    Connect-ExchangeOnline -UserPrincipalName $UserCredential.UserName -ShowProgress $true
    

    Once connected, run the following command to get the distribution groups and their members.

    Get-DistributionGroup | ForEach-Object { Get-DistributionGroupMember $_.Identity | Select-Object @{Name="GroupName";Expression={$_.Identity}}, Name, RecipientType }
    
    1. Identify Members: The output of these commands will list all distribution groups along with their members, including mail contacts, mail users, and external users. You can export this information to a CSV file for easier analysis.
    Get-DistributionGroup | ForEach-Object { Get-DistributionGroupMember $_.Identity | Select-Object @{Name="GroupName";Expression={$_.Identity}}, Name, RecipientType } | Export-Csv -Path "DistributionGroupMembers.csv" -NoTypeInformation
    

    By running these commands, you will be able to identify the distribution lists in both your on-premises and online environments and see which mail contacts, mail users, and external users are members of each list.


    If the answer is helpful please click on ACCEPT ANSWER as it could help other members of the Microsoft Q&A community who have similar questions and are looking for solutions.

    Thank you for your support and understanding.

    Best Wishes,

    Alex Zhang

    0 comments No comments

  2. Amit Singh 4,901 Reputation points
    2024-11-07T06:09:05.6166667+00:00

    Yes, you can identify which distribution lists both on-premises and in Exchange Online contain your mail contacts, mail users, and external users as members. Since you have a hybrid setup, you need to check both environments separately.

    1.       For On-Premises Exchange 2016:- Run the following command using PowerShell -

    Get-DistributionGroup | ForEach-Object {Get-DistributionGroupMember $_ | Where-Object {$_.PrimarySMTPAddress -eq "user@example.com"}}
    

    2.       For Exchange Online:- First, connect to Exchange Online PowerShell by running-

    Connect-ExchangeOnline -UserPrincipalName [admin@yourdomain.com]   
    

    Run the command to see all distribution lists -

    Get-DistributionGroup | ForEach-Object {Get-DistributionGroupMember $_ | Where-Object {$_.PrimarySMTPAddress -eq "user@example.com"}}
    

    Replace email address with your emails. Let me know if you have any query in above steps.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.