Forum Discussion
Exchange Online: New-Addresslist with RecipientFilter
- Feb 03, 2025
Few things. First, you should use -RecipientPreviewFilter instead of filter, but that's minor. Next, you should be grouping your conditions, as otherwise the logic gets distorted. In your example, the first two conditions need another () group.
{(((RecipientTypeDetails -eq 'UserMailbox') -or (RecipientTypeDetails -eq 'MailUser')) -and (UserPrincipalName -like '*contoso.com') -and (HiddenFromAddressListsEnabled -eq 'False'))}
Another thing to note is that the UserPrincipalName property is not available for all recipients and cmdlets. Should not be a problem in this specific example, but adding it just in case.
Lastly, there's an extra step you need to perform in Exchange Online, namely "touch" objects before they appear in new/modified address lists. In other words you need to change any property on said objects. It's explained in the article Dan linked below.
Few things. First, you should use -RecipientPreviewFilter instead of filter, but that's minor. Next, you should be grouping your conditions, as otherwise the logic gets distorted. In your example, the first two conditions need another () group.
{(((RecipientTypeDetails -eq 'UserMailbox') -or (RecipientTypeDetails -eq 'MailUser')) -and (UserPrincipalName -like '*contoso.com') -and (HiddenFromAddressListsEnabled -eq 'False'))}
Another thing to note is that the UserPrincipalName property is not available for all recipients and cmdlets. Should not be a problem in this specific example, but adding it just in case.
Lastly, there's an extra step you need to perform in Exchange Online, namely "touch" objects before they appear in new/modified address lists. In other words you need to change any property on said objects. It's explained in the article Dan linked below.
Touching the objects to force a change did it! Thank you!
I just added a description text for all users and did an Entra sync and all users immediately appeared in the addess list as wished.