May 16 2019 04:37 AM
HI
We have a dynamic distribution list setup on Office365 that includes everyone with exchange mailboxes...
We want to EXCLUDE a couple of people from this list. Anyone know how to do this?
Thanks
May 16 2019 04:40 AM
May 16 2019 06:25 AM
@ChrisHoardMVP thanks, we aren't using any attributes though to add users.
How do we exclude a user? Can we not do it by there email address?
There doesn't seam a option in the GUI - do we need to run some kind of powershell?
If so anyone got a example
Thanks
May 16 2019 10:13 AM
You simply need to adjust the recipient filter for the group. For example, if you want to exclude a single user by name:
((UsageLocation -eq 'Bulgaria') -and (Name -ne 'vasil'))
You can use any other attribute accordingly. Or target groups of users based on common criteria.
May 16 2019 11:48 AM
Thanks @VasilMichev
Sorry for the simple question, but how would I exclude a user called "test" were would i put that filter?
Is it done in powershell ? if so what is the actually command?
May 16 2019 11:24 PM
Yes, in PowerShell, via the Set-DynamicDistributionGroup cmdlet. Get the filter first:
Get-DynamicDistributionGroup | fl Name,RecipientFilter
Then append the additional inclusion/exclusion criteria as needed. You can ignore anything after the "-and (-not(Name -like 'SystemMailbox{*'))" part, this will be added automatically.
May 17 2019 01:32 AM
@VasilMichev thanks, i'm new to powershell so apologize for this but I haven't seamed to be able to get this to.
I entered the following.. but it didn't seam to work...
Get-DynamicDistributionGroup | fl <Distribution List Name>,RecipientFilter (-not(<Name of Mailbox I want to exclude> -like 'SystemMailbox{*'))
any help would be appreciated
Thanks
May 17 2019 04:01 AM
Just a update - as I believe I have managed to do this using the following command
Set-DynamicDistributionGroup -Identity DISTRIBUTIONLISTNAME -RecipientFilter {((RecipientType -eq 'UserMailbox') -and -not(Name -like 'MAILBOXTOEXCLUDENAME'))}
Just one other question - we a Mail Contact we want to add - do you know the command for adding that in?
May 17 2019 08:40 AM
That will be a bit more complicated as you already have a clause in there that only includes User mailboxes. Doesn't mean it's not possible, you simply need to add another group, but be careful not to interfere with the existing filter. With the above in mind, all you need is a simple:
-or (Name -eq "mail_contact_name")
or better yet, use the address:
-or (PrimarySmtpAddress -eq "mail@external.com")
Sep 28 2021 01:50 AM
@Pn1995 This PowerShell did not work for me
C:\Windows\system32> Get-DynamicDistributionGroup | fl Freedom,RecipientFilter
RecipientFilter : ((((RecipientType -eq 'UserMailbox') -or (RecipientType -eq 'MailUser'))) -and (-not(Name -like
'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and (-not(RecipientTypeDetailsValue -eq
'MailboxPlan')) -and (-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and
(-not(RecipientTypeDetailsValue -eq 'PublicFolderMailbox')) -and (-not(RecipientTypeDetailsValue -eq
'ArbitrationMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuditLogMailbox')) -and
(-not(RecipientTypeDetailsValue -eq 'AuxAuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq
'SupervisoryReviewPolicyMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'GuestMailUser')))
I inputted the user I want to exclude and it gave an error