Wildcards cannot be used as the first character. - Filtering Dynamic Distro Groups by domain
Ran into this annoying one.
The client asked me to create dynamic distribution groups and filter by domain. They have several companies under their umbrella.
So I created the first group. We'll call it SamusDental.
$filter = "(WindowsLiveID -eq '*@samusdental.com')"
$get-recipient -identity "All Users - SamusDental" -RecipientFilter $filter
Name | RecipientType |
---|---|
Annie.Lemon | UserMailbox |
Marcus.Lime | UserMailbox |
Stephanie.Cherry | UserMailbox |
JoAnne.Orange | UserMailbox |
Good.. Results. Let's set that as the DDG.
set-dynamicdistributiongroup -identity "All Users - SamusDental" -recipientfilter $filter
Write-ErrorMessage : |Microsoft.Exchange.Management.Tasks.RecipientTaskException|Wildcards cannot be used as the first character. Please revise the filter criteria.
Wut.. But it just worked in the get-recipient..
So I ran it several more times, testing @*samusdental.com.. no. *samusdental.com.. no. @samusdental.com.. no.
Nothing worked. If I set up the filter without the wildcard, no results were pulled, but if I set it up WITH the wildcard, and it pulled results, the set-ddg would not take the filter.
Finally found the solution:
$filter = "(RecipientTypeDetails -eq 'UserMailbox') -and (WindowsLiveID -eq '*@samusdental.com')"
For some reason having the RecipientTypeDetails property first, and then the wildcard on the domain second, worked fine.
Thanks, Microsoft.
1 comments:
Great readingg your blog post
Post a Comment