Dynamic Distribution Group Filter issue

Dean Hoile 61 Reputation points
2022-09-06T11:17:09.41+00:00

Hi.

I have setup a few new DDLs in Exchange Online via PoSH.

Basically I needed to have 4 DDLs for different office locations and I am using the attribute "CountryOrRegion" in the setup of the DDL to assign users to the group.

I already have a dynamic security group using the same attribute with a rule syntax of: (user.country -eq "Gibraltar")

From what I have seen the DDL should be able to use this attribute in the same way, so after I set the DDL up I could see it populating users but it looked like it stopped.

I tried to check this with Get-Recipient -RecipientPreviewFilter (Get-DynamicDistributionGroup "Gibraltar Employees New").RecipientFilter but it showed a number less than expected so I am not sure if the issues is either A. the filter is wrong

Which is: ((((RecipientTypeDetails -eq 'UserMailbox') -and (CountryOrRegion -eq 'Gibraltar'))) -and (-not(Name -like 'SystemMailbox{')) -and (-not(Name -like 'CAS_{')) -and (-not(RecipientTypeDetailsValue -eq 'MailboxPlan')) -and (-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'PublicFolderMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuxAuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'SupervisoryReviewPolicyMailbox')))

Note I only set the below - the rest was automatically added into the members filter after.

New-DynamicDistributionGroup -Name "Gibraltar Employees New" -RecipientFilter "(RecipientTypeDetails -eq 'UserMailbox') -and (CountryOrRegion -eq 'Gibraltar')"

Or B. I am not getting the full list because of a limitation in my commands.

I did try the below script but I still get a limited number, perhaps I need an -All flag or something?

$DDGs = Get-DynamicDistributionGroup
$results = foreach ($ddg in $DDGs) {Get-Recipient All $true -RecipientPreviewFilter (Get-DynamicDistributionGroup $ddg.PrimarySmtpAddress).RecipientFilter -RecipientTypeDetails UserMailbox,SharedMailbox,RoomMailbox,EquipmentMailbox,TeamMailbox, DiscoveryMailbox,MailUser, MailContact, DynamicDistributionGroup, MailUniversalDistributionGroup,MailUniversalSecurityGroup,RoomList,GuestMailUser,PublicFolder,GroupMailbox | Add-Member -MemberType NoteProperty -Name DDG -Value $ddg.PrimarySmtpAddress -PassThru | select DDG,DisplayName, PrimarySmtpAddress,RecipientTypeDetails} $results | Export-CSV -path 'c:\Temp\DDGList.csv'

Thanks

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. BenOu-MSFT 586 Reputation points
    2022-09-07T09:22:20.903+00:00

    Hi@

    You can connect Exchange Online and run “get-recipient -filter "(CountryOrRegion -eq 'GL')" | select name,primarySMTPaddress,countryorregion” command. Then you can check whether the result of the showing number is less than you expect. If it is ,please verify whether the CountryOrRegion is populated for all relevant users .

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    If this Answer is helpful, please click "Accept Answer" to upvote it. If you have extra questions about this answer, please click "Comment" and I will come to your aid.

    1 person found this answer helpful.

  2. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2022-09-06T12:21:23.753+00:00

    The filter looks OK to me, just make sure that the CountryOrRegion is populated for all relevant users. Also, you are filtering just by UserMailboxes, which automatically excludes every other recipient type (including shared mailboxes), which is why your example under the B scenario will not work correctly (double-filtering on RecipientTypeDetails).


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.