Forum Discussion
How to exclude a user from a Dynamic Distribution List
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.
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?
- VasilMichevMay 17, 2019MVP
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.
- Pn1995May 17, 2019Brass Contributor
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
- Pn1995May 17, 2019Brass Contributor
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?