This page looks best with JavaScript enabled

Exclude shared mailboxes from Dynamic Distribution Group

 ·  ☕ 1 min read  ·  ✍️ Chris Titus

This shows you how to exclude shared mailboxes from a Dynamic Distribution Group in Exchange Online. We will be using Powershell to make sure your shared mailboxes don’t get spam in them.

Exclude Shared Mailboxes


Connect to O365 in PS:

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

Exclude Shared Mailboxes with this filter command:

set-DynamicDistributionGroup -Name "" -RecipientFilter {((RecipientType -eq 'UserMailbox') -and -not (RecipientTypeDetailsValue -eq 'SharedMailbox'))}


Afterward, Verify in Exchange Admin Console. You always want to prevent your shared mailboxes from getting spammed in a distribution group. Consequently, I’d highly recommend setting a requirement to send to-these dynamic mailboxes. This will prevent every employee from sending emails to everyone, which will be a bad thing.

I live stream on Twitch and encourage you to drop in and ask a question. I regularly publish on YouTube and, but if you need immediate assistance, check out the Terminal Cafe with Discord Invite Link.

Share on

Chris Titus
Chris Titus
Tech Content Creator