Forum Discussion

JanE40's avatar
JanE40
Copper Contributor
Feb 03, 2025
Solved

Exchange Online: New-Addresslist with RecipientFilter

Hello, our client will move from OnPrem Exchange to Cloud, i just set up an hybrid connection where everything works fine so far. I wanted to migrate the custom address lists from OnPrem to Online ...
  • VasilMichev's avatar
    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.