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.

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,843 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,344 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,361 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,447 questions
{count} vote

3 answers

Sort by: Most helpful
  1. Andy David - MVP 141.3K Reputation points MVP
    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,351 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

  3. Gérémy Vernet 0 Reputation points
    2023-06-27T10:14:16.7366667+00:00

    Hi, is this statement still accurate ?

    Because i'm facing same but didn't find ExtensionAttribute anymore, in on-prem AD, cloudExtensionAttribute instead.

    Is it the same ?

    Sorry for post's exhumation

    0 comments No comments