Powershell Get-DynamicDistributionGroupMember with filter on CustomAttribute

gino matthys 0 Reputation points
2023-02-24T11:21:20.6+00:00

Will someone confirm if this works for an Dynamic Distribution List

Set-DynamicDistributionGroup -Identity "dl_AllEmployees@Contoso.com" -ConditionalStateOrProvince Florida -CustomAttribute1 Florida

Get-DynamicDistributionGroupMember -Identity "dl_AllEmployees@Contoso.com" gives nothing as result. Even after 2 hours waiting.

If I remove the filter Customattribute1 I'm getting the result of all accounts with have their State/Provine attribute equals Florida

Microsoft Exchange Online
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
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 108.1K Reputation points MVP
    2023-02-24T12:47:19.1333333+00:00

    The example above effectively sets the value of CustomAttribute1 on the DDG object, it does not affect the filter used to determine membership. If that's the idea, you should be using -ConditionalCustomAttribute1 instead of -CustomAttribute1. Better yet, use the -RecipientFilter parameter with a proper OPATH filter.

    0 comments No comments

  2. Aholic Liang-MSFT 13,856 Reputation points Microsoft Vendor
    2023-02-28T09:04:32.8566667+00:00

    Hi @gino matthys ,

    As Michev says, it is more appropriate to use the RecipientFilter parameter to set member filters.

    If filtered directly by the conditional parameter, users who must have true for these conditions can join the group.

    You can refer to the following commands to set up dynamic distribution groups:

    Set-DynamicDistributionGroup  -Identity "Dynamic1group@contoso.onmicrosoft.com"  -RecipientFilter "(RecipientTypeDetails -eq 'UserMailbox') -and ((CustomAttribute1 -eq 'Florida')  -or (StateOrProvince -eq 'Florida'))"
    
    

    2023-2-27-4


    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

    0 comments No comments

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.