Valid String Comparison Operators for -RecipientFilter Parameter in Exchange Online

Taranjeet Malik 571 Reputation points
2023-10-11T05:04:18.31+00:00

Hi

I'm working to build Dynamic Distribution Groups in Exchange Online that require filtering the recipients based on custom attributes and values of those attributes are in the format <something Department1>, <somethingelse Department1>, <something Department2>, <somethingelse Department2> and so on.

Read here that Exchange Online doesn't allow a wildcard prefix to filter recipients--> https://learn.microsoft.com/en-us/powershell/module/exchange/new-dynamicdistributiongroup?view=exchange-ps#-recipientfilter

The relevant section in the above article cross-references this article--> https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comparison_operators?view=powershell-7.3

which states that we can use -match and -notmatch string comparison operators, but when trying to use those operators to create DDL, it shows the following error suggesting these are not valid operators:

DDLErrorOct112023

Can someone please help suggest a way to filter recipients when they have a common string as prefix? I see this as a very common requirement and sure someone out there has figured out a solution.

Thanks

Taranjeet Singh

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Windows for business Windows Server User experience PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2023-10-11T07:30:24.79+00:00

    The -match operator is used for regex matches, those are not supported in recipient filters afaik. Only the -like operator is supported, with a wildcard as prefix/suffix. Though even that is not supported for some parameters.

    Use these two articles to get the list of supported properties and operators:

    https://learn.microsoft.com/en-us/powershell/exchange/filter-properties?view=exchange-ps

    https://learn.microsoft.com/en-us/powershell/exchange/recipientfilter-properties?view=exchange-ps

    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.