Knowledgebase
emscom > emscom Help Desk > Knowledgebase

Search help:


Exchange - powershell: create all mail users distribution list

Solution

Microsoft have removed direct mailbox delivery to the All Company M365 group.

A dynamic dstribution list can be created to enable emailing of all mailboxes.

The recommended approach is to first create the list in the Exchange admin portal and then update the recipient filter with Powershell to exclude shared mailboxes. Creating the group from Powershell directly prevents list  ownership being assigned to a non-licenced administrator

Create the group in the Exchange Admnin Portal, selecting 'Users with mailbox' from the default filters provided.

Open powershell and connect-ExchangeOnline -userPrincipalName admnin@contoso.com

Enter the following command

Set-DynamicDistributionGroup -Identity "All Mail Users" -RecipientFilter { (RecipientTypeDetails -eq 'UserMailbox') -and (-not (RecipientTypeDetails -eq 'SharedMailbox')) }

Check group memebership using the Powershell command

Get-Recipient -RecipientPreviewFilter (Get-DynamicDistributionGroup "All Mail Users").RecipientFilter | fl DisplayName

Note: a lengthy set of conditions is automatically appended to the recipient filter. The Exchange admin portal will replace the default recipient filter checkboxes with a text box containing the complete recipient custom filter.

 

The following powershell commands creates a dynamic distribution list directly but does not allow an owner to be set.

PS>connect-ExchangeOnline -UserPrincipalName admin@contoso.com

New-DynamicDistributionGroup -name "All Mail Users" -RecipientFilter "(RecipientTypeDetails -eq 'UserMailbox') -and (-not (RecipientTypeDetails -eq 'SharedMailbox'))" 

Verify group membership

Get-Recipient -RecipientPreviewFilter (Get-DynamicDistributionGroup "All Mail Users").RecipientFilter | fl DisplayName

 
Was this article helpful? yes / no
Related articles Exchange - Recreate active user mailbox
Exchange - Shared Mailbox Access (not Mac mail)
Exchange - Shared Mailbox Access (macmail)
Exchange - Shared mailbox on secondary domain
OneDrive share with external guests using group
Article details
Article ID: 264
Category: Exchange
Date added: 14-05-2026 13:40:19
Views: 5
Rating (Votes): Article not rated yet (0)

 
« Go back

 
Powered by Help Desk Software HESK, in partnership with SysAid Technologies