Exclude shared\resource mailboxes from a dynamic distribution group

October 2, 2018 | by iaur | posted as Adminstration, Microsoft 365

Scenario

  • You created a Dynamic Distribution group in Admin center and would like certain recipient to be excluded

Steps

  1. Connect to EXO using PowerShell
  2. Run the cmdlets below accordingly
Get-DynamicDistributionGroup -Identity testdynamic@faceresionem.onmicrosoft.com | Set-DynamicDistributionGroup  -RecipientFilter {(-not(RecipientTypeDetailsValue -eq ‘SharedMailbox’)) -and (-not(RecipientTypeDetailsValue -eq ‘RoomMailbox’)) -and (-not(RecipientTypeDetailsValue -eq ‘EquipmentMailbox’))}
note:
– this is a one liner cmdlet
– this will exclude shared, room, equipment from the testdynamic group’s member list
Get-DynamicDistributionGroup -Identity testdynamic@faceresionem.onmicrosoft.com | Set-DynamicDistributionGroup  -RecipientFilter {(-not(RecipientTypeDetailsValue -eq ‘SharedMailbox’)) -and (-not(RecipientTypeDetailsValue -eq ‘RoomMailbox’)) -and (-not(RecipientTypeDetailsValue -eq ‘EquipmentMailbox’) -and -not(Name -like ‘chino.m’))}
note:
– this is a one liner cmdlet
– this will exclude shared, room, equipment and the alias “chino.m” from the testdynamic group’s members list
Getting the recipient-filter settings
Get-DynamicDistributionGroup -Identity testdynamic@faceresionem.onmicrosoft.com | Format-List Name,RecipientTypeDetails,RecipientFilter,PrimarySmtpAddress
This will display the current recipient filter settings
Display the members of the dynamic distribution group
$List=Get-DynamicDistributionGroup -Identity testdynamic@faceresionem.onmicrosoft.com
This encapsulate the dynamic group to the $List variable
Get-Recipient -RecipientPreviewFilter $List.RecipientFilter
This will display the current member of the dynamic group

Reference

https://answers.microsoft.com/en-us/msoffice/forum/msoffice_o365admin/excluding-shared-mailboxes-from-dynamic/b0735a41-1143-404d-bbd7-89e85301b8d4

https://docs.microsoft.com/en-us/powershell/exchange/exchange-server/recipient-filters/recipientfilter-properties?redirectedfrom=MSDN&view=exchange-ps

Feedback or Help?

Should you have one, click here

Boring Ads. Pardon me :)