Forum Discussion

SunfieldPaulC's avatar
SunfieldPaulC
Copper Contributor
Nov 07, 2022
Solved

Trying to update old dynamic distribution group to include exchange contacts

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')))

 

  • VasilMichev's avatar
    VasilMichev
    Nov 08, 2022
    You should be grouping similar clauses together, via parenthesis, otherwise the logic gets broken. So:

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

6 Replies

  • SunfieldPaulC's avatar
    SunfieldPaulC
    Copper Contributor

    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{*')))"
    • VasilMichev's avatar
      VasilMichev
      MVP
      You should be grouping similar clauses together, via parenthesis, otherwise the logic gets broken. So:

      (blabla) -and ((RecipientType -eq 'UserMailbox') -or (RecipientType -eq 'MailContact'))
  • Update/remove the RecipientType clause, as you're currently only including mailboxes.
    • SunfieldPaulC's avatar
      SunfieldPaulC
      Copper Contributor

      VasilMichev 

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

      • VasilMichev's avatar
        VasilMichev
        MVP
        You can use something like:

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

Resources