The EmaiI Signature Web Portal - Help Center

IT Pro: How to exclude Office365 Groups and Distribution Lists using powershell (Bulk exclusion)

This guide will walk you through the steps on how to exclude all distribution lists and Office365 Mail enabled Groups using Powershell. For reference - Exchange cmdlet syntax

Problem: Sender may receive a bounce-back message when sending to Office365 Groups. Problem: Messages sent to distribution groups are missing or identified as spam.


Open Powershell using elevated Access

# Connect to your Exchange Online Tenant


# Assumes the Transport rule is named 'Xink-Auto-ReRouting-Catcher' and directs the rule name to the variable $XinkRule

$XinkRule = Get-TransportRule -Filter "Description -like 'Xink-Auto-ReRouting-Catcher'" -state enabled -ExcludeConditionActionDetails $false

# Captures the current list of Distribution Lists and Office365 Groups.

$DistList = Get-DistributionGroup -ResultSize Unlimited | Select -ExpandProperty alias

$GroupList = Get-UnifiedGroup -ResultSize Unlimited | Select -ExpandProperty alias

#Applies the $DistList $GroupList from $XinkRule exceptions

$XinkRule | Set-TransportRule -ExceptIfSentToMemberof $Distlist -ExceptIfAnyOfRecipientAddressContainsWords $GroupList

NOTE: If you received an error connecting to exchange online you need to run Install-Module -Name ExchangeOnlineManagement

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.