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.
trinity2007Asked:
Who is Participating?
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"))))))
0

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....
0
Amit KumarCommented:
Try this one

Set-DynamicDistributionGroup -Identity "DLAllUniformedEmployees” -RecipientFilter (!(cn=SystemMailbox{*})(&(&(& (mailnickname=*) (| (objectCategory=msExchDynamicDistributionList) &(!(mailnickname="DL-AllHR -")))))))
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Amit KumarCommented:
Else try this

Set-DynamicDistributionGroup -Identity "DLAllUniformedEmployees” -RecipientFilter (-not(name -like "SystemMailbox{*}") -and (mailnickname=*) -or (objectCategory=msExchDynamicDistributionList) -and (-not(mailnickname="DL-AllHR -")))
0
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...
0
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"))
0
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.
0
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*")}
0
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!!
0
Amit KumarCommented:
Great to know,, hope my assistance helped you to find solution.
0
trinity2007Author Commented:
Yes, you were great on getting started down the right path though.  Learned different syntax input variations.
Thank you!
0
trinity2007Author Commented:
Accepted multiple solutions as various syntax options were on the right track.
Thank you,
0
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
Exchange

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.