Dynamic DL Filter on Address List Membership

Copper Contributor

I am trying to create a new dynamic DL in exchange online that will include on-prem and online users.  I know to do that the recipienttype "mailuser" has to be included.  The issue with that is all mailboxes on-prem are mail users in O365 including rooms and shared mailboxes.  I'd like to exclude these as much as possible.  I know that I can include "AddressListMembership" in the recipient filter, but I am struggling with that.  I'd like to exclude any user that is included in the address list "\All Rooms".  If I run the command "Get-MailUser -ResultSize Unlimited | ? {$_.AddressListMembership -match "All Rooms"}", I only get rooms back that are on-prem.  Handy - that's what I was going for.  But if I try to create a DDL that includes just those same mailboxes (-RecipientFilter {(RecipientTypeDetails -eq "MailUser") -and (AddressListMembership -like "\All Rooms*")}) I don't get the same thing.  Since AddressListMembership is an array and not a string, the -like comparison isn't working.  If I can create a DDL with just the rooms, I should be able to reverse that and create a DDL that excludes the rooms.  This isn't an issue if the rooms are in O365 as I can limit that using RecipientTypeDetails -eq "UserMailbox" and on-prem with RemoteUserMailbox.  It's the issue with O365 having everything as a mail user as the recipient type and recipient type details vs. on-prem breaking that out to what type of remote mailbox it is.  Any help would be appreciated.

4 Replies

I guess you missed the part where the AddressListMembership only works against the DistinguishedName attribute. Try this:

 

(Get-AddressList "\All Rooms").DistinguishedName

Get-Recipient -RecipientPreviewFilter {AddressListMembership -eq 'CN=All Rooms,CN=All Address Lists,CN=Address Lists Container,CN=Configuration,CN=tenant.onmicrosoft.com,CN=ConfigurationUnits,DC=EURPR03A001,DC=prod,DC=outlook,DC=com'}

You're welcome :)

 

I take it it works for your scenario? I only bothered to check it against Get-Recipient.

It did.  I was able to create a DDL with just the rooms, and the reverse of -ne should be excluding the rooms from a DDL.