Need your input how to achieve these conditions ( dynamic distribution group )

365 Test Tenant 11 Reputation points

Create a dynamic distribution list that reads the user's company name and user Mailbox. Dynamic distribution list should include only enabled user mailbox accounts. Any blocked accounts should be automatically excluded from the dynamic distribution list. Any assistance will be much appreciated.

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,368 questions
{count} votes

2 answers

Sort by: Most helpful
  1. 2022-11-30T04:45:55.073+00:00

    Hello @365 Test Tenant and thanks for reaching out. Out of the box, is not possible to exclude disabled accounts in Exchange Dynamic Distribution Groups since the AccountDisabled attribute is not a recognized filterable property. You can, however, set the account disabled value to one of the Exchange Custom Attributes, all which are filterable, so that you can achieve the same desired result. Setting the value to a custom attribute would preferably be done by a scheduled job or similar.


    Updating the custom attribute
       Get-User -RecipientTypeDetails "UserMailbox" | % {Set-Mailbox -Identity $_ -CustomAttribute1 $_.AccountDisabled }  
    Creating the Dynamic Distribution Group
       New-DynamicDistributionGroup -ConditionalCompany <COMPANY> -ConditionalCustomAttribute1 "False" # Extra parameters  

    Let us know if you need additional assistance. If the answer was helpful, please accept it and complete the quality survey so that others can find a solution.

    0 comments No comments

  2. Aholic Liang-MSFT 13,826 Reputation points Microsoft Vendor

    Hi @365 Test Tenant

    What is blocked accounts? Are you referring to mailboxes without licenses?
    If so ,please don’t worry it .If the mailbox has been unlicensed, it should be converted to a shared mailbox .
    So you can refer to the following command to create a dynamic distribution group with company name and user mailbox as conditions.

    New-DynamicDistributionGroup -Name "contoso group” -RecipientFilter "(RecipientType -eq 'UserMailbox')  -and (Company -like 'contoso' )"  

    About how to create dynamic distribution group in Exchange Online, you could refer to the following links:

    Manage dynamic distribution group in Exchange Online | Microsoft Learn
    New-DynamicDistributionGroup (ExchangePowerShell) | Microsoft Learn
    For more filters, please see the following link:
    Filterable properties for the RecipientFilter parameter | Microsoft Learn

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.