How to Find Empty or Unused Distribution Groups in Microsoft 365 –


Managing Microsoft 365 environments efficiently involves cleaning up unused resources—distribution groups are no exception. Over time, these groups can accumulate, especially when staff leave or departments change. In many environments, hundreds of distribution lists (DLs) remain active despite being unused or completely empty.

This guide will show you how to identify:

  • Unused Distribution Groups
  • Empty Distribution Groups

By using PowerShell and connecting to Exchange Online, you can easily spot and export these outdated groups.


Table of Contents

Find Unused Distribution Groups in Exchange Online

Microsoft 365 doesn’t automatically flag unused groups, but you can leverage the Start-HistoricalSearch command to perform a Message Trace Report on distribution group usage.

Prerequisites

First, install and connect to Exchange Online PowerShell (EXO):

powershellCopyEditConnect-ExchangeOnline

Script to Identify Unused Distribution Groups

The script below scans all distribution groups and sends a message trace request for each one:

powershellCopyEditforeach ($group in Get-DistributionGroup) {
    Start-HistoricalSearch -ReportTitle $group.PrimarySmtpAddress `
                           -StartDate 01/01/2024 `
                           -EndDate 03/01/2024 `
                           -ReportType MessageTrace `
                           -RecipientAddress $group.PrimarySmtpAddress `
                           -NotifyAddress [email protected]
}

⚠️ Limit: Microsoft 365 only processes 250 historical search requests at a time. To bypass this, apply a filter to narrow the scope.

Example: Filter by Naming Convention

You can target groups using a naming pattern, like all that contain “DL” in their name:

powershellCopyEditforeach ($group in Get-DistributionGroup | Where-Object {$_.Name -like "*DL*"}) {
    Start-HistoricalSearch -ReportTitle $group.PrimarySmtpAddress `
                           -StartDate 01/01/2024 `
                           -EndDate 03/01/2024 `
                           -ReportType MessageTrace `
                           -RecipientAddress $group.PrimarySmtpAddress `
                           -NotifyAddress [email protected]
}

Find Empty Distribution Groups

Groups with no members are typically no longer needed. Over time, as staff accounts are removed, groups can become completely empty if not maintained.

PowerShell Script to List Empty Distribution Groups

This script scans your tenant for empty groups and exports the list to a CSV:

powershellCopyEditConnect-ExchangeOnline

$emptyGroups = foreach ($grp in Get-DistributionGroup -ResultSize Unlimited) {
    if (@(Get-DistributionGroupMember –Identity $grp.DistinguishedName -ResultSize Unlimited).Count –eq 0 ) {
        [PsCustomObject]@{
            DisplayName = $grp.DisplayName
            PrimarySMTPAddress = $grp.PrimarySMTPAddress
            DistinguishedName = $grp.DistinguishedName
        }
    }
}

$emptyGroups | Export-Csv 'C:\Data\DLsToRemove.csv' -NoTypeInformation

This is a powerful way to prepare for a cleanup initiative and remove stale groups safely.


Wrapping Up

Regularly reviewing your distribution groups improves the hygiene of your Microsoft 365 environment, reduces clutter, and ensures more accurate mail flow reporting. Whether you’re hunting for inactive groups or spotting empty ones, PowerShell provides the tools you need.



Share this content:

I am a passionate blogger with extensive experience in web design. As a seasoned YouTube SEO expert, I have helped numerous creators optimize their content for maximum visibility.

Leave a Comment