Exchange 2010 - Dynamic Distribution Lists

Michel Fournier 1 Reputation point
2020-08-17T18:52:33.603+00:00

I would like to know what would be the best way to exclude from a distribution list - users that their AD accounts are disabled and their exchange account are hidden from GAL and a message delievry restrictions has been added "Only senders in the following list"(due that we currently cannot delete any accounts and needed to stop all mail flow).

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,578 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,669 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ashok M 6,516 Reputation points
    2020-08-18T07:06:07.673+00:00

    Hi,

    Could you please share the detailed version of your exchange server?

    Get-Exchangeserver | select name,admindisplayversion

    Please note that Exchange 2010 support is till October 2020, so plan for the upgrade of exchange to the supported versions.

    If I understood correctly, you are looking to exclude the users in dynamic distribution lists. Disabled AD accounts, hidden from GAL accounts. If so, please try the below command to exclude the disabled AD accounts in dynamic distribution lists,

    Set-DynamicDistributionGroup -name "New List " -RecipientFilter {((RecipientType -eq 'UserMailbox') -and (HiddenFromAddressListsEnabled -eq 'True'))}

    Set-DynamicDistributionGroup -name "New List " -RecipientFilter {((RecipientType -eq 'UserMailbox') -and -not(UserAccountControl -like 'AccountDisabled') )}


  2. Kael Yao-MSFT 37,651 Reputation points Microsoft Vendor
    2020-08-18T07:14:56.607+00:00

    Hi,
    You can use the UserAccountControl propertity of the recipientfilter parameter.
    For example, there is a list containing all the members in the Organizational Unit “IT support”.
    The following command excludes users whose accounts have been disabled in the Active Directory.

    Set-DynamicDistributionGroup –identity <GroupName> -RecipientFilter{(RecipientType –eq “Usermailbox”) -and (UserAccountControl –ne “AccountDisabled,NormalAccount”)} –RecipientContainer “contoso.com/IT support”  
    

    You can also use the following command to exclude users by their names:

      Set-DynamicDistributionGroup -Identity <GroupName> -RecipientFilter {((RecipientType -eq 'UserMailbox') -and -not(Name -like '<User_to_be_exclude>'))}  
      
    

    In additional, based on my research, disabling the users’ mailboxes will also take effect.
    While it may remove the users from not only a dynamic distribution list but all the other address lists and stop the mail flow to these mailboxes.
    And it will also delete all the Exchange related attributes of the user in active directory.

    Here is the test in my lab:
    I created a dynamic distribution group named IT group. It contains users who are in the IT department.
    DLmember.ps1 is a script to get all the users in this dynamic distribution group. Currently there are two users, IT1 and IT2.
    18188-001.png

    When a message is send to this group, both users will receive the mail.
    18177-002.png

    If IT1’s mailbox is disabled, it will be removed from the dynamic distribution group.
    18229-003.png

    And will no longer receive mails which are sent to this group.
    18257-004.png


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.