Set-DynamicDistributionGroup Insanity

I don't think this should be so difficult, but it is (for me anyway.)  I just need to add an additional Exchange server to the recipient filter.  Initially I had three listed, and it worked fine.  This is the command i ran, and like i said, no issues...

set-dynamicdistributiongroup "Some Dynamic DL" {((((((((((((((ServerName -eq 'Server1') -or (ServerName -eq 'Server2'))) -or (ServerName -eq 'Server3'))) -and (-not(Name -like 'SystemMailbox{*')))) -and (-not(Name -like 'CAS_{*')))) -and (-not(Name -like 'SystemMailbox{*')))) -and (-not(Name -like 'CAS_{*')))) -and (-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and (-not(RecipientTypeDetailsValue -eq 'MailboxPlan')) -and (-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox')))}

Now, when i add a fourth server, i get an error.  All i'm doing is adding -or (ServerName -eq 'Server4')))  So, the new command looks like this:

set-dynamicdistributiongroup "Some Dynamic DL" {((((((((((((((ServerName -eq 'Server1') -or (ServerName -eq 'Server2'))) -or (ServerName -eq 'Server3'))) -or (ServerName -eq 'Server4'))) -and (-not(Name -like 'SystemMailbox{*')))) -and (-not(Name -like 'CAS_{*')))) -and (-not(Name -like 'SystemMailbox{*')))) -and (-not(Name -like 'CAS_{*')))) -and (-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and (-not(RecipientTypeDetailsValue -eq 'MailboxPlan')) -and (-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox')))}

When i run the above command, i get this error:

<position> : Missing closing '}' in statement block.
    + CategoryInfo          : ParserError: (CloseBraceToken:TokenId) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingEndCurlyBrace

Which statement block is it referring to??  I guess a '}' is missing, but I've no idea where it should go.  Can anyone point me in the right direction?

Thanks in advance.

February 5th, 2015 3:54pm

Try below.

set-dynamicdistributiongroup "Some Dynamic DL" {((((((((((((((ServerName -eq 'Server1'))-or (ServerName -eq 'Server2'))) -or (ServerName -eq 'Server3'))))-or (ServerName -eq 'Server4'))) -and (-not(Name -like 'SystemMailbox{*')))))-and (-not(Name -like 'CAS_{*')))) -and(-not(Name -like 'SystemMailbox{*')-and (-not(Name -like 'CAS_{*'))) -and(-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and(-not(RecipientTypeDetailsValue -eq 'MailboxPlan')) -and(-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and(-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox'))}

Free Windows Admin Tool Kit Click here and download it now
February 5th, 2015 4:32pm

Didn't work, new error message..

A positional parameter cannot be found that accepts argument '((((((((((((((ServerName -eq 'Server1')) -or (ServerName -eq 'Server2'))) -or (ServerName -eq 'Server3')))) -or (ServerName -eq 'Server4'))) -and (-not(Name -like 'SystemMailbox{*')))))-and (-not(Name -like 'CAS_{*')))) -and(-not(Name -like 'SystemMailbox{*')-and (-not(Name -like 'CAS_{*'))) -and(-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and(-not(RecipientTypeDetailsValue -eq 'MailboxPlan')) -and(-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and(-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox'))'.
    + CategoryInfo          : InvalidArgument: (:) [Set-DynamicDistributionGroup], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Set-DynamicDistributionGroup
    + PSComputerName        : Server.company.com

February 6th, 2015 7:42am

Never mind. I forgot to add back "-recipientfilter".  Your syntax worked.  Thanks much.  :)
Free Windows Admin Tool Kit Click here and download it now
February 6th, 2015 8:10am

Didn't work, new error message..

A positional parameter cannot be found that accepts argument '((((((((((((((ServerName -eq 'Server1')) -or (ServerName -eq 'Server2'))) -or (ServerName -eq 'Server3')))) -or (ServerName -eq 'Server4'))) -and (-not(Name -like 'SystemMailbox{*')))))-and (-not(Name -like 'CAS_{*')))) -and(-not(Name -like 'SystemMailbox{*')-and (-not(Name -like 'CAS_{*'))) -and(-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and(-not(RecipientTypeDetailsValue -eq 'MailboxPlan')) -and(-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and(-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox'))'.
    + CategoryInfo          : InvalidArgument: (:) [Set-DynamicDistributionGroup], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Set-DynamicDistributionGroup
    + PSComputerName        : Server.company.com

  • Edited by blinkyjesus Friday, February 06, 2015 12:44 PM
February 6th, 2015 3:41pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics