SOLVED

Trying to update old dynamic distribution group to include exchange contacts

New Contributor

Im trying to update an old dynamic distribution group to include exchange contacts.

 

Can anyone help with this?

 

 

((((((((((((((((((((((CustomAttribute1 -ne 'EXCLUDE') -and (RecipientType -eq 'UserMailbox'))) -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')))) -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')))

 

6 Replies
Update/remove the RecipientType clause, as you're currently only including mailboxes.

@Vasil Michev 

What would be the attrib just to add contacts as I don't want to include anything other than mailboxes and contacts?

You can use something like:

(RecipientType -eq 'UserMailbox') -or (RecipientType -eq 'MailContact')

@Vasil Michev 

I have added the mail contacts but for some reason it is ignoring the EXCLUDE in the custom attribs. Any ideas?

 

set-dynamicdistributiongroup -identity "Everyone" -RecipientFilter "((((((((((((((((((((((CustomAttribute1 -ne 'EXCLUDE') -and (RecipientType -eq 'UserMailbox'))) -or (RecipientType -eq 'MailContact')-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')))) -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')))"

I have tried stripping back the filter but still cannot get it to exclude accounts with the exclude custom attribute set.

 

set-dynamicdistributiongroup -identity "Everyone" -RecipientFilter "((((CustomAttribute1 -ne 'EXCLUDE') -or (ExtensionCustomAttribute1 -ne 'EXCLUDE')) -and (RecipientType -eq 'UserMailbox') -or (RecipientType -eq 'MailContact')) -and (-not(Name -like 'SystemMailbox{*')))"
best response confirmed by SunfieldPaulC (New Contributor)
Solution
You should be grouping similar clauses together, via parenthesis, otherwise the logic gets broken. So:

(blabla) -and ((RecipientType -eq 'UserMailbox') -or (RecipientType -eq 'MailContact'))