question

berket2020 avatar image
0 Votes"
berket2020 asked YukiSun-MSFT commented

Exchange Online create custom address list filter by email

Hello

I would like to create a custom address list "New List" in Exchange online and add any users with a specific domain such as @contoso.com in their email address.

And then verify the members of the list?

What would be the powershell command ?

Thanks

office-exchange-online-itpro
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

michev avatar image
0 Votes"
michev answered

New-AddressList, then specify the name and recipient filter to use. For example, you can use a filter like this:

((Alias -ne $null) -and (EmailAddresses -like '*@domain.com'))

For additional details and examples, refer to the official documentation here: https://docs.microsoft.com/en-us/exchange/address-books/address-lists/manage-address-lists
Make sure you also check the section about updating lists, as in ExO this requires you to "touch" each object.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

YukiSun-MSFT avatar image
0 Votes"
YukiSun-MSFT answered YukiSun-MSFT commented

Hi @berket2020,

According to this official document, it's not supported to use the wildcard as a prefix for the RecipientFilter parameter in Exchange Online Powershell, so it's not feasible to use recipient filter like (EmailAddresses -like '*@domain.com') to directly create the customized address list.

As a workaround, we can set one of the custom attribute for the mailboxes who have PrimarySmtpAddress with specific domain such as @contoso.com, for example:

 Get-Mailbox | Where{$_.RecipientType -eq 'UserMailbox' -and $_.PrimarySmtpAddress -like "*contoso.com"} | Set-Mailbox -CustomAttribute10 "DomainContoso"

Then the custom address list can be created based on the conditional custom attribute:

  New-AddressList -Name "DomainContoso AddressList" -IncludedRecipients AllRecipients -ConditionalCustomAttribute10 "DomainContoso"

To view the members of the address list, run the command below:

 $AL = Get-AddressList -Identity "DomainContoso AddressList"; Get-Recipient -ResultSize unlimited -RecipientPreviewFilter $AL.RecipientFilter | select Name,PrimarySmtpAddress,HiddenFromAddressListsEnabled

If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 10
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @YukiSun-MSFT Thank you

IIs there a way to do it by Company name if the company name field is populated?

Thanks

0 Votes 0 ·

Hi @berket2020,

Yes, you can do it use the Company Name by running command similar to below:

 New-AddressList -Name 'TestAddressList' -RecipientFilter {(Company -eq 'CONTOSO')}

If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 Votes 0 ·

@YukiSun-MSFT how can i see the members after the address list is created?

Also this is a hybrid environment. Will this process work if run on exchange online powershell?

0 Votes 0 ·
Show more comments