How to exclude tenants with a specifc custom attribute from allusers DL?

Deleted
Not applicable

I made a dynamic group for all users in the organisation but I am trying to exclude some emails from this group via custom attribute. I have set below recipient filter but still everyone is on this list. can you help me to fix this filter?

((-not(CustomAttribute1 -like 'exclude')) -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')))
1 Reply

Easiest way to check whether a specific filter will work as expected is to test it against the Get-Recipient cmdlets. For example:

 

Get-Recipient -RecipientPreviewFilter {-not (CustomAttribute1 -like 'exclude') }

Other than that, check your attribute values and make sure they evaluate against the -like statement.