Feb 22 2024 06:30 AM
I have a dynamic distribution group that uses Office locations for its recipient filter.
It is able to pick up all of the users needed, however, there are a few service accounts I want to exclude from the dynamic group.
I know the easy answer is to remove the Office info from the service accounts, however I'd prefer not to. As I'm using this example as a test for excluding users from future dynamic distribution groups that we're going to be migrating to exchange online.
Here is an example of the recipient filter in use:
$filter = "((Office -eq 'Spokane, WA') -or (Office -eq 'Sandpoint, ID') -and (RecipientType -eq 'UserMailbox') -and (RecipientTypeDetails -eq 'UserMailbox')) -and (-not(UserPrincipalName -like 'email address removed for privacy reasons' -or 'email address removed for privacy reasons')))"
The service accounts still appear in the dynamic group's recipient list.
Feb 22 2024 11:39 PM
Feb 23 2024 10:05 AM
@VasilMichev
I have been using the (get-dynamicdistributiongroupmember -identity $identity | Select-object DisplayName,PrimarySmtpAddress) to get recipients.
I've also been using:
$filter = $TheRecipientFilterSyntax
Get-Recipient -filter $filter | Select-object DisplayName,PrimarySmtpAddress
I'm testing with the following now:
"(((Office -eq 'Spokane, WA')) -or ((Office -eq 'Sandpoint, ID')) -and (RecipientType -eq 'UserMailbox') -and (RecipientTypeDetails -eq 'UserMailbox') -and (-not(Name -like '<service-account's-name>')) -and (-not(Name -like '<service-account's-name>*')))"
I've got a wild-card on the last one because there's a handful of service accounts with ascending numbers that match that ANR.
Thanks for the tip! Hopefully this gets the results I'm looking for.
Will check back in next week.
Mar 06 2024 02:30 PM