EmployeeType AD Attribute is an Invalid Filter syntax when creating New-DynamicDistributionGroup

RS84 6 Reputation points
2021-11-24T16:02:50.623+00:00

Hi guys, on our Exchange Management Server, I have imported-module ActiveDirectory.. I am creating new DDL's.
I have successfully been able to create a new DDL with City as a filer, for example:

New-DynamicDistributionGroup -DisplayName allstaff.London -Name allstaff.London -Alias allstaff.London -RecipientContainer "localdomain.com/OU/EMEA" -RecipientFilter "(city -eq 'London')"

^ This works fine.

But I want to also create a new DDL this time using EmployeeType = Perm as a RecipientFilter.
This is what i'm doing:

New-DynamicDistributionGroup -DisplayName allstaff.Perm -Name allstaff.Perm -Alias allstaff.Perm -RecipientContainer "localdomain.com/OU/EMEA" -RecipientFilter "(EmployeeType -eq 'Perm')"

However, when I run this, I get the following error:


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.
"('employeetype' -eq 'Perm')" at position 2."

  • CategoryInfo : WriteError: (:) [New-DynamicDistributionGroup], ParameterBindingException
  • FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.Exchange.Management.RecipientTasks.NewDynamicDistributionGroup
  • PSComputerName : servername.localdomain.com

I am running this in Exchange Mgmt Shell, and I have imported AD Module.

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Exchange | Exchange Server | Management
Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} vote

2 answers

Sort by: Most helpful
  1. Andy David - MVP 157.8K Reputation points MVP Volunteer Moderator
    2021-11-24T16:15:27.48+00:00

    Thats not a valid filter:
    https://learn.microsoft.com/en-us/powershell/exchange/recipientfilter-properties?view=exchange-ps

    You'll have to use something else other than "EmployeeType"

    Perhaps a custom attribute or group etc...

    0 comments No comments

  2. Limitless Technology 39,926 Reputation points
    2021-11-25T09:19:08.647+00:00

    Hello RandeepSahota

    The parameter supports an OPATH filter with limited filterable properties and comparison operators. According to the documentation, employeeType is not filterable with the OPATH filter.

    As an alternative, you could have an automated or scripted process that updates an attribute that can be conditionally queried by the dynamic group. Here is an example of using the employeeType to update extensionAttribute1.

    Get-AdUser -Filter "employeeType -eq 'Vendor'" |
    Set-AdUser -Replace @{'extensionAttribute1' = 'Vendor'}
    Then you can create a dynamic distribution group based on ConditionalCustomAttribute1, which maps to extensionAttribute1 in AD.

    New-DynamicDistributionGroup -Name "Vendor Dynamic Group" -IncludedRecipients "MailboxUsers" -ConditionalCustomAttribute1 "Vendor"
    Note that you can query for more than one value since -ConditionalCustomAttribute1 accepts an array. So you could pass -ConditionalCustomAttribute1 "Vendor","Contractor", which would look for the values Vendor or Contractor in extensionAttribute1.


    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.