Link to home
Start Free TrialLog in
Avatar of John Wan
John WanFlag for Australia

asked on

Exchange 2010 Dynamic Groups Recipient Filter format

I am trying to create a custom recipient filter to create dynamic distribution groups.

New-DynamicDistributionGroup -Name “TestGroup" -OrganizationalUnit "domain.com/Enterprise/Query-Based Groups" -RecipientContainer "domain.com/Staff” -RecipientFilter {(RecipientType -eq ‘UserMailbox’ -and Office -eq "Location1”) -and (-not(Department –eq ‘Contractors’))}

1. Its not clear when to use 'location1' or "location1" Appreciate any clarification on that
2. the above syntax is incorrect. I can use the above to create a group for that location, but i want to be able to exclude users with a specific department field. Its too unwieldy to include 99 of 100 departments, i prefer to just filter out the ones i dont want.
3. how to i have multiple departments excluded

Many thanks
Avatar of Amit Kumar
Amit Kumar
Flag of India image

Hi.

You are creating DDL for those are based on location1 and recipient type is user mailbox, if you don't want them to filter location wise then remove -and Office -eq "Location1” syntax. To filter multiple departments use or condition as below mentioned.

New-DynamicDistributionGroup -Name “TestGroup" -OrganizationalUnit "domain.com/Enterprise/Query-Based Groups" -RecipientContainer "domain.com/Staff” -RecipientFilter {(RecipientType -eq ‘UserMailbox’ -and Office -eq "Location1”) -and (-not(Department –eq ‘Contractors’ -or Department –eq ‘Contractors1’))}
Avatar of John Wan

ASKER

Thank you. But when i run it get a syntax error. Is something wrong with the way the command is structured?
please paste the error
Invoke-Command : Cannot bind parameter 'RecipientFilter' to the target. Exception setting "RecipientFilter": "Invalid filter syntax. For a description of the filter parameter syntax see the command help.
"(RecipientType -eq ‘UserMailbox’ -and Office -eq “TestGroup”) -and (-not(Department –eq ‘Contractors’ -or Department –eq
 ‘Contractors1’))" at position 20."
At C:\Users\auser\AppData\Roaming\Microsoft\Exchange\RemotePowerShell\exchange-server.domain.com\exchange-server
.domain.com.psm1:25743 char:29
+             $scriptCmd = { & <<<<  $script:InvokeCommand `
    + CategoryInfo          : WriteError: (:) [New-DynamicDistributionGroup], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.Exchange.Management.RecipientTasks.NewDynamicDistributionGroup
thanks, any other thoughts on why this command doesn't work?
ASKER CERTIFIED SOLUTION
Avatar of Amit Kumar
Amit Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much - apologies for late response, but this was really appreciated.

Cheers