Forum Discussion
Update Dynamic Distribution List
we are a hybrid environment, running exchange 2019 and have a few DDLs which have been around from previous exchange versions. One of the DDLs i need to modify is the below. Its hard to read and i am trying to work out where i add the extra fields i want to include. I am looking to add another custom attribute and possibly include members of a security group. Is there anyway to make this easier to read so i know where to add things? Any other tips?
((((((((((((((((((((((((((Company -eq 'Contoso') -and (CustomAttribute4 -eq 'City'))) -and (((((CustomAttribute7 -eq 'Group') -or (CustomAttribute7 -eq 'Contractor'))) -or (CustomAttribute7 -eq 'Permanent'))))) -and (((RecipientType -eq 'UserMailbox') -or (((RecipientType -eq 'MailUser') -and (CustomAttribute12 -ne 'Excluded'))))))) -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')))
2 Replies
- np123Copper Contributor
ok, thanks. So in terms of running the command, co-pilot told me the below command would work (i havent tested it as its an important DDL). Do you think this will work or not go with including what will be added back?
Set-DynamicDistributionGroup -Identity "Your-DDG-Name" -RecipientFilter "( ( (((((((((((((((((((((((Company -eq 'Contoso') -and (CustomAttribute4 -eq 'City')) -and ((CustomAttribute7 -eq 'Group') -or (CustomAttribute7 -eq 'Contractor') -or (CustomAttribute7 -eq 'Permanent'))) -and ((RecipientType -eq 'UserMailbox') -or ((RecipientType -eq 'MailUser') -and (CustomAttribute12 -ne 'Excluded')))) -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')) ) -or (CustomAttribute3 -eq 'test')" You can ignore anything after this bit:
((((((((((((((((((((((((((Company -eq 'Contoso') -and (CustomAttribute4 -eq 'City'))) -and (((((CustomAttribute7 -eq 'Group') -or (CustomAttribute7 -eq 'Contractor'))) -or (CustomAttribute7 -eq 'Permanent'))))) -and (((RecipientType -eq 'UserMailbox') -or (((RecipientType -eq 'MailUser') -and (CustomAttribute12 -ne 'Excluded')))))))as it will be added back after you make the changes. For the above, cleanup the parenthesis, and make sure the correct grouping is used between the individual clauses, then append another -or with the desired changes.