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