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.
Powershell Get-DynamicDistributionGroupMember with filter on CustomAttribute
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
2 answers
Sort by: Most helpful
-
-
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'))"
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