Exchange 2010 - Modify Filter for Dynamic Distribution Group

I would like to modify the filter for a Dynamic Distribution group to exclude 1 specific group from the list:

We have a Dynamic Distribution group called:  DL-All Employees that has the following filter applied:

(&(!cn=SystemMailbox{*})(&(&(& (mailnickname=*) (| (objectCategory=msExchDynamicDistributionList) )))))

I'm not understanding how the above syntax associates what groups are listed in this DDG, but in the 'preview' option I see several DL groups listed; for instance:  DL-All HR, DL-All Accounting, DL-All Sales, DL-All IT, DL-All Develepors and so on.  What I would like to accomplish is to exclude the  DL-All HR group from this filter.  

  I realize that this will need to be done through the exchange shell with the Set-DynamicDistributionGroup command, but can't seem to find the correct command syntax to exclude the DL-All HR group.

Thank you for your assistance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Amit KumarCommented:
Try this:

(&(!cn=SystemMailbox{*})(&(&(& (mailnickname=*) (| (objectCategory=msExchDynamicDistributionList) &(!mailnickname="DL-AllHR"))))))

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
trinity2007Author Commented:
Tried the command:
Set-DynamicDistributionGroup -Identity "DLAllUniformedEmployees” (&(!cn=SystemMailbox{*})(&(&(& (mailnickname=*) (| (objectCategory=msExchDynamicDistributionList) &(!mailnickname="DL-AllHR -"))))))

Received about a missing expression after unary operator '!' line:1 char:70
    which is the cn=SystememMailbox.........
Must have missed an expression or just need to make adjustments to the command....
Amit KumarCommented:
Try this one

Set-DynamicDistributionGroup -Identity "DLAllUniformedEmployees” -RecipientFilter (!(cn=SystemMailbox{*})(&(&(& (mailnickname=*) (| (objectCategory=msExchDynamicDistributionList) &(!(mailnickname="DL-AllHR -")))))))
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Amit KumarCommented:
Else try this

Set-DynamicDistributionGroup -Identity "DLAllUniformedEmployees” -RecipientFilter (-not(name -like "SystemMailbox{*}") -and (mailnickname=*) -or (objectCategory=msExchDynamicDistributionList) -and (-not(mailnickname="DL-AllHR -")))
trinity2007Author Commented:
Hmm..error on both:
Set-DynamicDistributionGroup -Identity "DLAllUniformedEmployees” -RecipientFilter (!(cn=SystemMailbox{*})(&(&(& (mailnickname=*) (| (objectCategory=msExchDynamicDistributionList) &(!(mailnickname="DL-AllHR -")))))))
     Error Message:  Unexpected token ')' in expression or statement:  At line:1 char:107
and ran the second one:
Set-DynamicDistributionGroup -Identity "DLAllUniformedEmployees” -RecipientFilter (-not(name -like "SystemMailbox{*}") -and (mailnickname=*) -or (objectCategory=msExchDynamicDistributionList) -and (-not(mailnickname="DL-AllHR -")))
    Error Message:  The term 'name' is not recognized as the name of a cmdlet, function, script file or operable program.  check the spelling of the name, or if a path was included, verify that the path is correct:  At line:1 char:93

I know it's a matter of getting the syntax in the exact content...
Amit KumarCommented:
Let's make it simple as you want to add only DDL so you chosen objectcategory as DDL. please run below one:

Set-DynamicDistributionGroup -Identity "DLAllUniformedEmployees” -RecipientFilter (objectCategory=msExchDynamicDistributionList) &(!(mailnickname="DL-AllHR"))
trinity2007Author Commented:
Doesn't like the ampersand, received message that 'Ampersand' is not allowed.  The & operator is reserved for future use; use "&" to pass ampersand as a string:
Set it as "&" (not sure if that is correct)
Set-DynamicDistributionGroup -Identity "DLAllUniformedEmployees” -RecipientFilter (objectCategory=msExchDynamicDistributionList) "&" (!(mailnickname="DL-AllHR"))
       Get message:  
          The term 'objectCategory=msExchDynamicDistributionList' is not recognized as the name of a cmdlet, function, script file or operable program...check the spelling......etc..

Thank you for your patience.
Amit KumarCommented:
Really sorry, DDL is very tricky..

Try this one please. verify mailNickName whcih I have specified is the correct or not in case of first condition and second one.

Set-DynamicDistributionGroup -Identity <DynDLName> -RecipientFilter {((mailNickName -like "*DL-ALL*") -and -not (mailNickName -like "*DL-ALLHR*")}
trinity2007Author Commented:
I had another thought:  I've changed the container where the DL group filters on (it was set at the root), since the group that I no longer need included is based on another container (OU), it is now removed from the equation.  Actually works out better as the original DL group didn't need to filter from the root...
Thank you for your assistance!!
Amit KumarCommented:
Great to know,, hope my assistance helped you to find solution.
trinity2007Author Commented:
Yes, you were great on getting started down the right path though.  Learned different syntax input variations.
Thank you!
trinity2007Author Commented:
Accepted multiple solutions as various syntax options were on the right track.
Thank you,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.