Exchange 2007 SP2 Setting up New DynamicDistributionGroup - command shell

Trying to set up a new dynamic distribution group, but keep getting syntax errors.  Not sure if my parenthesis are in the correct order or the { }.  Below is an example of one of the variations I've tried.


New-DynamicDistributionGroup -Name "trend" -OrganizationalUnit "" -RecipientFilter {(RecipientType -eq 'UserMailbox' -and (Title -like '*Trend*' -or Title -like '*Desktop*') –and –not(Name –like ‘SystemMailbox{*’) –and –not(Name –like ‘CAS_{*’))}

Receive message:
New-DynamicDistributionGroup : Cannot bind parameter 'RecipientFilter' to the t
arget. Exception setting "RecipientFilter": """ is not a valid operator. For a
list of supported operators see the command help.
"(RecipientType -eq 'UserMailbox' -and (Title -like '*Trend*' -or Title -like '
*Desktop*') -and -not(Name -like `SystemMailbox{*') -and -not(Name -like `CAS_{
*'))" at position 91."
At line:1 char:110
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.

Will SzymkowskiSenior Solution ArchitectCommented:
Based on your syntax you are missing the "$_." on all of your attributes i.e.$_.RecipientType.

Should look something like that below...

New-DynamicDistributionGroup -Name "trend" -OrganizationalUnit "" -RecipientFilter {$_.RecipientType -eq 'UserMailbox' -and $_.Title -like '*Trend*' -or $_.Title -like '*Desktop*') –and –not $_.Name –like "SystemMailbox{*" –and –not $_.Name –like 'CAS_{*'
DebelloCaminusAuthor Commented:
Made a few adjustments to the brackets...

Still getting error:

New-DynamicDistributionGroup : Cannot bind parameter 'RecipientFilter' to the t
arget. Exception setting "RecipientFilter": "Invalid filter syntax. For a descr
iption of the filter parameter syntax see the command help.
"$_.RecipientType -eq 'UserMailbox' -and $_.Title -like '*Trend*' -or $_.Title
-like '*Desktop*'" at position 1."
At line:1 char:110
+ New-DynamicDistributionGroup -Name "trend" -OrganizationalUnit "" -RecipientFilter <<<<  {$_.RecipientType -eq 'UserMailbox' -and
 $_.Title -like '*Trend*' -or $_.Title -like '*Desktop*'} -and -not $_.Name -li
ke "SystemMailbox{*" -and -not $_.Name -like 'CAS_{*'
    + CategoryInfo          : WriteError: (:) [New-DynamicDistributionGroup],
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.Exchange.Manage
Will SzymkowskiSenior Solution ArchitectCommented:
My apologize as I was thinking of a different powershell switch. The syntax will also be incorrect. Please take a look a this link and follow the "RecipientFilter" syntax that is outlined in Example 2.

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
DebelloCaminusAuthor Commented:
Thank you...that worked!!
Will SzymkowskiSenior Solution ArchitectCommented:
Perfect glad to help!
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.