Distribution lists in Office 365 – administration tips

Distribution lists are known under a few different names. Distribution groups, contact groups and distribution lists – all refer to the same feature. The primary purpose of a distribution list is to send emails to multiple recipients – yes, as simple as that. The simplicity of their design and the idea behind distribution groups make them an essential email feature. It’s no wonder they have been around since the earliest versions of Exchange Server and that they can be found in Office 365, as well. Although they have survived in a very similar form, Office 365 also offers a redesigned form of distribution lists – Office 365 Groups.

Distribution lists in Office 365

Office 365 focuses on using the upgraded version of distribution groups – Office 365 Groups. I will start with a quick comparison between the two features. Later on, I will describe a few common administration tasks concerning Office 365 distribution lists.

Distribution lists and Office 365 Groups

In Office 365, distribution lists are slowly losing ground because of Office 365 Groups. The great thing about Groups is that they can serve the very same purpose and have many additional features. They integrate not only with Outlook, but also with SharePoint, Yammer, OneNote and other Office 365 services. So is there a reason to use distribution groups if you can have their upgraded version? It depends.

Office 365 Groups are great for collaboration. Having an automatically-generated SharePoint site collection and integration with other Office 365 features helps users work with each other. However, while a Group is great for particular teams or projects, is it always something worth setting up? There are situations in which you simply want to send emails to a certain collection of contacts. What is the point of cluttering your SharePoint with ghost sites no one will ever use? Dealing with inactive distribution lists is enough of an administrative problem.

If you want to learn more about similarities and differences between the two, take a look at: in-depth comparison between Office 365 Groups and Distribution lists.

The fact is, it does not really matter if Office 365 Groups are a better solution or not. Distribution lists still can be found in every Office 365 organization, so it is good to know what exactly you are working with. Especially because there are some distribution lists which you cannot upgrade to Groups.

Distribution list limits in Office 365

There are a few limits which apply to Office 365 distribution groups that you should be aware of:

  • member count for a distribution list: 100,000 (50,000 for organizations using AAD Connect, 15,000 if there is a slightly outdated DirSync in place).
  • number of groups created by a single user/admin: 300,000.
  • number of distribution group owners: 10.
  • size for messages sent to groups with 5,000-99,999 members: 25MB.

The limits apply to all Office 365 subscriptions, it does not matter if you have Office 365 Business Essentials, or Office 365 Enterprise E5 subscription – the limits stay the same. The only difference is if you have Exchange Online as a standalone option. In this case, each plan allows one user to create up to 250 instead of 300,000 distribution groups.

A complete list of distribution group limits is available here.

As you can see, those limits are not real roadblocks in most cases. Together with the fact that contact groups can be user-created, it unfortunately means that cleaning those lists might be a common and repetitive task for each admin.

How to find & delete inactive distribution lists in Office 365

What is an inactive distribution list? It is a list to which nobody sends any emails. Sometimes, they are created for test purposes or by mistake (and forgotten about), sometimes they are simply created not to be used, ever. An empty distribution list is a list with no members. It is a good practice to remove both empty and inactive groups as to keep the organization and GAL clean. Although both inactive and empty distribution lists are similar, the way to deal with them is not quite similar.

Now, there is a slight problem with finding inactive distribution lists in Office 365. Normally, back in the old, on-prem days, you could search through message tracking logs to see which distribution lists are in use. What is more, since on the on-prem Exchange the logs are also physical text files, there is no problem in keeping them for as long as you want and even backing them up. As a result, with the right configuration, you could very easily make sure if a distribution group has ever been used. In Office 365, it is not as simple as that. Office 365 Message Trace works differently.

Mind to connect to Exchange Online with PowerShell before running any cmdlets. Message trace can show results from the last 10 days. Since the “expanded” message status is reserved for distribution lists, it can be used to limit the results to those groups only:

Get-MessageTrace -Status expanded -startdate (get-date).AddDays(-10) -EndDate (Get-Date) | group recipientaddress | select name,count

The cmdlet above returns all messages sent to distribution lists, groups them, and displays the message count. The problem is, this method of determining inactive groups is not that reliable. Not using a distribution group for ten days does not make it completely inactive, yet. Theoretically, you could use the Historical Search feature to search for the messages sent in the last 90, and not 10 days. Unfortunately, Get-HistoricalSearch requires either sender, recipient, or messageid attribute to run successfully. Checking all senders manually is not an option, and checking each recipient (distribution list) separately seems counterproductive.

As a workaround, you can run message trace periodically and create your own message tracking log.

How to trace inactive distribution lists manually

The cmdlet below gets all messages sent to distribution groups in the last 10 days and exports the most basic information to a CSV.

Get-MessageTrace -Status expanded -startdate (get-date).AddDays(-10) -EndDate (Get-Date) |select received,recipientaddress,status| Export-Csv C:\SentToDL.csv -Append

If you run this script every 10 days, you will be able to log all email sent to distribution lists.

To learn how actively users send to distribution lists, run:

import-csv C:\Users\a.lewis\dist2.csv | group recipientaddress | select name,count

The cmdlet returns DL addresses together with a number of emails sent to them. Still, all the data up to now is about active distribution lists. To find out which of the distribution lists in your organizations are inactive, run the following:

$ActiveDL = (import-csv C:\SentToDL.csv | group RecipientAddress).name;
$allDL = (Get-DistributionGroup).PrimarySMTPAddress;
$inactive = $AllDL | where {$activeDL -notcontains $_};
$inactive

You will receive a list of all distribution lists nobody has sent emails to. Mind that the results depend on how long you have been keeping your manual message tracing. What is more, the $inactive variable will include contact groups which have just been created. Therefore, it might be a good idea to delete groups which are listed more than once.

How to find & delete empty distribution lists in Office 365

Finding empty distribution lists, on the contrary, is a quick and easy task. Once you establish remote connection to your Office 365 tenant, run the following cmdlet:

get-distributiongroup |? {!(get-distributiongroupmember $_.PrimarySMTPAddress).count}

This one-liner returns all empty distribution lists. To delete them, pipeline the results to Remove-DistributionGroup:

get-distributiongroup |? {!(get-distributiongroupmember $_.PrimarySMTPAddress).count} | Remove-DistributionGroup -WhatIf

the -WhatIf switch only shows you which distribution groups will be deleted. To actually delete them, replace -WhatIf with -Confirm:$false.

Upgrade distribution lists to Office 365 Groups

If you decide you want more from your distribution lists, you can always upgrade them to Office 365 Groups. You can do it with a single cmdlet: Upgrade-DistributionGroup. There is a catch, though – a distribution list has to fill certain requirements. You can check which of distribution lists in your company can be upgraded with Get-EligibleDistributionGroupForMigration. You can find some of the reasons why a distribution list cannot be upgraded, below:

  • Distribution groups managed on premises. It means that if you have a directory synchronization in place, you will have to recreate a group in Office 365 before you upgrade it.
  • Nested distribution groups. A distribution list cannot have another distribution group as its member, and cannot be a member of other groups.
  • Distribution lists without owners.
  • Dynamic distribution lists & security groups.

For a complete list of distribution groups which are not eligible for upgrade, visit this article.

One way to deal with non-upgradable groups is to create them directly in your target tenant. If you want to recreate distribution lists in Exchange Online, you need to migrate them.

Migrate a distribution group to Office 365

Distribution list migration is an elaborate name for exporting and then importing them, along with their member lists. To export distribution group members to a CSV file, run the following cmdlet:

Get-DistributionGroupMember "DistributionGroupName" | Export-Csv dl.csv

The cmdlet will create a CSV file in your current location. If a group contains nested lists, it is a good idea to export their members directly into the target CSV.

Get-DistributionGroupMember "DistributionGroupName" | where recipienttype -eq "UserMailbox" | export-csv nested.csv -Append;
$nested = (Get-DistributionGroupMember "DistributionGroupName” | where recipienttype -ne "UserMailbox");
foreach ($list in $nested)
{Get-DistributionGroupMember $list.PrimarySmtpAddress | export-csv nested.csv -append}

This short script will add all distribution list members, including those from nested groups, directly to the CSV file of your choosing. After that, if you want to create a new distribution list and import members in bulk, first create the group and assign its owner:

New-DistributionGroup "Example" -ManagedBy "Admin"

After that, use the CSV file you created earlier to populate the new group:

$dlmembers = import-csv testers.csv
foreach ($dlmember in $dlmembers) {Add-DistributionGroupMember "Example" -member $dlmember.PrimarySmtpAddress}

As a result, you will recreate a distribution list in the target tenant.

Useful articles:

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

*