Share via

Query on Distribution Lists

Glenn Maxwell 13,961 Reputation points
2026-06-28T23:47:25.14+00:00

Hi All,

We are running an Exchange Server Subscription Edition (SE) hybrid environment. User mailboxes are created on-premises and then migrated to Exchange Online. we have Distribution Lists both in Onprem and Online.

I have a distribution list in Exchange Online (for example, DL1) that contains more than 30 nested distribution lists. Some of the nested distribution lists are hosted on-premises, while others reside in Exchange Online.

I need to export all the individual members of DL1, including members contained within all nested distribution lists (both on-premises and Exchange Online) to csv file. i want output in below format.

dl

In other words, I would like to recursively expand all nested distribution groups and identify the immediate parent distribution list from which each user is inherited. Can anyone help me with powershell script to fetch this information.

Exchange | Exchange Server | Other
Exchange | Exchange Server | Other

A robust email, calendaring, and collaboration platform developed by Microsoft, designed for enterprise-level communication and data management.Miscellaneous topics that do not fit into specific categories.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Teddie-D 18,700 Reputation points Microsoft External Staff Moderator
    2026-06-29T03:51:19.9033333+00:00

    Hi @Glenn Maxwell

    This reference is relevant and helpful for understanding how to export nested distribution group members using PowerShell: Export Office 365 Nested Distribution Group Members Using PowerShell.

    This information is provided as a convenience. The site is not controlled by Microsoft, and Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please ensure that you fully understand the risks before using any suggestions from the above link.

    It demonstrates a recursive approach to expanding nested distribution groups and generating a detailed membership report. This is necessary because the native Get-DistributionGroupMember cmdlet only returns direct members by default.

    However, there are important limitations to consider. The script is designed for Exchange Online only and it does not fully support hybrid environments where distribution groups exist across both Exchange Online and on‑premises Exchange.

    In a hybrid environment, directory-synchronized (on-premises) groups must be queried from on-premises Exchange. Cloud-only groups must be queried from Exchange Online

    While the recursive logic used in the script is valid and reusable, it cannot be applied directly without modification. The main differences are:

    • Exchange Online uses Connect-ExchangeOnline
    • On-premises Exchange requires Exchange Management Shell or remote PowerShell session.

    For a complete solution in hybrid, the approach should be:

    • Detect whether each group is cloud-only or directory-synchronized
    • Query the group from the correct environment
    • Apply recursive expansion logic across both environments
    • Consolidate results into a unified report

    I hope this information is helpful.


    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.

    Was this answer helpful?

    0 comments No comments

Your answer

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