Home

How to exclude a user from a Dynamic Distribution List

%3CLINGO-SUB%20id%3D%22lingo-sub-574561%22%20slang%3D%22en-US%22%3EHow%20to%20exclude%20a%20user%20from%20a%20Dynamic%20Distribution%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-574561%22%20slang%3D%22en-US%22%3E%3CP%3EHI%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20have%20a%20dynamic%20distribution%20list%20setup%20on%20Office365%20that%20includes%20everyone%20with%20exchange%20mailboxes...%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20423px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F113720iCF9D7602D509E5A2%2Fimage-dimensions%2F423x357%3Fv%3D1.0%22%20width%3D%22423%22%20height%3D%22357%22%20alt%3D%22Capture.PNG%22%20title%3D%22Capture.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20want%20to%20EXCLUDE%20a%20couple%20of%20people%20from%20this%20list.%20Anyone%20know%20how%20to%20do%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-574561%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%20Online%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-574568%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20a%20user%20from%20a%20Dynamic%20Distribution%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-574568%22%20slang%3D%22en-US%22%3EShould%20be%20able%20to%20do%20this%20by%20attribute.%20See%20article%20here%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FOffice-365%2FExclude-a-single-E-mail-from-Dynamic-distribution-Group%2Ftd-p%2F281390%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FOffice-365%2FExclude-a-single-E-mail-from-Dynamic-distribution-Group%2Ftd-p%2F281390%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EHope%20that%20answers%20your%20question!%3CBR%20%2F%3E%3CBR%20%2F%3EBest%2C%20Chris%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-574853%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20a%20user%20from%20a%20Dynamic%20Distribution%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-574853%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F169605%22%20target%3D%22_blank%22%3E%40Christopher%20Hoard%3C%2FA%3E%26nbsp%3Bthanks%2C%20we%20aren't%20using%20any%20attributes%20though%20to%20add%20users.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20do%20we%20exclude%20a%20user%3F%20Can%20we%20not%20do%20it%20by%20there%20email%20address%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20doesn't%20seam%20a%20option%20in%20the%20GUI%20-%20do%20we%20need%20to%20run%20some%20kind%20of%20powershell%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20so%20anyone%20got%20a%20example%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-574884%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20a%20user%20from%20a%20Dynamic%20Distribution%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-574884%22%20slang%3D%22en-US%22%3EAFAIK%20you%20can't%20do%20it%20by%20their%20actual%20email%20address.%3CBR%20%2F%3E%3CBR%20%2F%3ESee%20the%20official%20document%20by%20Microsoft%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fexchange%2Frecipients%2Fdynamic-distribution-groups%2Fdynamic-distribution-groups%3Fview%3Dexchserver-2019%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fexchange%2Frecipients%2Fdynamic-distribution-groups%2Fdynamic-distribution-groups%3Fview%3Dexchserver-2019%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EA%20dynamic%20distribution%20group%20includes%20any%20recipient%20in%20Active%20Directory%20with%20attribute%20values%20that%20match%20its%20filter.%20These%20attributes%20include%20Container%2C%20Province%2C%20Company%2C%20Department%20or%20Custom%20Attribute.%20Most%20organisations%20I%20know%20use%20a%20custom%20attribute.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20article%20will%20show%20you%20how%20to%20create%20via%20the%20GUI%20or%20the%20shell.%3CBR%20%2F%3E%3CBR%20%2F%3EBest%2C%20Chris%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-575860%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20a%20user%20from%20a%20Dynamic%20Distribution%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-575860%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20simply%20need%20to%20adjust%20the%20recipient%20filter%20for%20the%20group.%20For%20example%2C%20if%20you%20want%20to%20exclude%20a%20single%20user%20by%20name%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E((UsageLocation%20-eq%20'Bulgaria')%20-and%20(Name%20-ne%20'vasil'))%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EYou%20can%20use%20any%20other%20attribute%20accordingly.%20Or%20target%20groups%20of%20users%20based%20on%20common%20criteria.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-576348%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20a%20user%20from%20a%20Dynamic%20Distribution%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-576348%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESorry%20for%20the%20simple%20question%2C%20but%20how%20would%20I%20exclude%20a%20user%20called%20%22test%22%20were%20would%20i%20put%20that%20filter%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20it%20done%20in%20powershell%20%3F%20if%20so%20what%20is%20the%20actually%20command%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-579884%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20a%20user%20from%20a%20Dynamic%20Distribution%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-579884%22%20slang%3D%22en-US%22%3E%3CP%3EYes%2C%20in%20PowerShell%2C%20via%20the%26nbsp%3B%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3ESet-DynamicDistributionGroup%3C%2FFONT%3E%20cmdlet.%20Get%20the%20filter%20first%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EGet-DynamicDistributionGroup%20%7C%20fl%20Name%2CRecipientFilter%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EThen%20append%20the%20additional%20inclusion%2Fexclusion%20criteria%20as%20needed.%20You%20can%20ignore%20anything%20after%20the%20%22-and%20(-not(Name%20-like%20'SystemMailbox%7B*'))%22%20part%2C%20this%20will%20be%20added%20automatically.%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-580776%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20a%20user%20from%20a%20Dynamic%20Distribution%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-580776%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%26nbsp%3Bthanks%2C%20i'm%20new%20to%20powershell%20so%20apologize%20for%20this%20but%20I%20haven't%20seamed%20to%20be%20able%20to%20get%20this%20to.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20entered%20the%20following..%20but%20it%20didn't%20seam%20to%20work...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGet-DynamicDistributionGroup%20%7C%20fl%20%3CDISTRIBUTION%20list%3D%22%22%20name%3D%22%22%3E%2CRecipientFilter%20(-not(%3CNAME%20of%3D%22%22%20mailbox%3D%22%22%20i%3D%22%22%20want%3D%22%22%20to%3D%22%22%20exclude%3D%22%22%3E%20-like%20'SystemMailbox%7B*'))%3C%2FNAME%3E%3C%2FDISTRIBUTION%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eany%20help%20would%20be%20appreciated%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-581225%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20a%20user%20from%20a%20Dynamic%20Distribution%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-581225%22%20slang%3D%22en-US%22%3E%3CP%3EJust%20a%20update%20-%20as%20I%20believe%20I%20have%20managed%20to%20do%20this%20using%20the%20following%20command%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESet-DynamicDistributionGroup%20-Identity%20DISTRIBUTIONLISTNAME%20-RecipientFilter%20%7B((RecipientType%20-eq%20'UserMailbox')%20-and%20-not(Name%20-like%20'MAILBOXTOEXCLUDENAME'))%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJust%20one%20other%20question%20-%20we%20a%20Mail%20Contact%20we%20want%20to%20add%20-%20do%20you%20know%20the%20command%20for%20adding%20that%20in%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-582999%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20a%20user%20from%20a%20Dynamic%20Distribution%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-582999%22%20slang%3D%22en-US%22%3E%3CP%3EThat%20will%20be%20a%20bit%20more%20complicated%20as%20you%20already%20have%20a%20clause%20in%20there%20that%20only%20includes%20User%20mailboxes.%20Doesn't%20mean%20it's%20not%20possible%2C%20you%20simply%20need%20to%20add%20another%20group%2C%20but%20be%20careful%20not%20to%20interfere%20with%20the%20existing%20filter.%20With%20the%20above%20in%20mind%2C%20all%20you%20need%20is%20a%20simple%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E-or%20(Name%20-eq%20%22mail_contact_name%22)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eor%20better%20yet%2C%20use%20the%20address%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E-or%20(PrimarySmtpAddress%20-eq%20%22mail%40external.com%22)%3C%2FP%3E%3C%2FLINGO-BODY%3E
Pn1995
Contributor

HI

 

We have a dynamic distribution list setup on Office365 that includes everyone with exchange mailboxes...Capture.PNG

 

We want to EXCLUDE a couple of people from this list. Anyone know how to do this?

 

Thanks

 

9 Replies
Should be able to do this by attribute. See article here

https://techcommunity.microsoft.com/t5/Office-365/Exclude-a-single-E-mail-from-Dynamic-distribution-...

Hope that answers your question!

Best, Chris

@Christopher Hoard 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

AFAIK you can't do it by their actual email address.

See the official document by Microsoft

https://docs.microsoft.com/en-us/exchange/recipients/dynamic-distribution-groups/dynamic-distributio...

A dynamic distribution group includes any recipient in Active Directory with attribute values that match its filter. These attributes include Container, Province, Company, Department or Custom Attribute. Most organisations I know use a custom attribute.

The article will show you how to create via the GUI or the shell.

Best, Chris

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 @Vasil Michev

 

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?

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.

@Vasil Michev 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

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?

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")