This guide will walk you through the steps on how to exclude Office365 Mail enabled Groups using Powershell. For reference - Exchange cmdlet syntax
Problem: Sender may receive a bounce-back message when sending to Office365 Groups.
Solution
Open Powershell using elevated Access
# Connect to your Exchange Online Tenant
Connect-ExchangeOnline
# 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 the Office365 Groups.
$GroupList = Get-UnifiedGroup -ResultSize Unlimited | Select -ExpandProperty alias
#Applies the $GroupList from $XinkRule exceptions
$XinkRule | Set-TransportRule -ExceptIfAnyOfRecipientAddressContainsWords $GroupList
NOTE: If you received an error connecting to exchange online you need to run Install-Module -Name ExchangeOnlineManagement