Forum Discussion
Sam240
Apr 01, 2022Copper Contributor
Users not part of office distribution lists PowerShell
I'm looking to find office365 users whose primary SMTP is our domain.com that are not part of certain office365 distribution lists we have. For example Dist1, Dist2, Dist3, Dist4 and export the resul...
May 17, 2022
Ah, yes! You're right! But PrimarySmtpAddress doesn't look like something you can filter regarding Primary address Filterable properties for the RecipientFilter parameter | Microsoft Docs
Newbie_Jones
May 17, 2022Brass Contributor
It's in that list. It doesn't have a LDAP Display Name but it says "string (wildcards accepted)".
The following works in my org. Need to use -eq or -like. (Match is not a supported operator).
Get-Mailbox -Filter {PrimarySmtpAddress -like 'testuser*'}
There are always some attributes\commands where its better or easier to use client side filtering, but I always try\check if it can be done server side where possible.
The following works in my org. Need to use -eq or -like. (Match is not a supported operator).
Get-Mailbox -Filter {PrimarySmtpAddress -like 'testuser*'}
There are always some attributes\commands where its better or easier to use client side filtering, but I always try\check if it can be done server side where possible.
- May 17, 2022It also says in the comments column, scroll right on page:
Don't use the PrimarySmtpAddress property; use the EmailAddresses property instead. Any filter that uses the PrimarySmtpAddress property will also search values in the EmailAddresses property. For example, if a mailbox has the primary email address dario@contoso.com, and the additional proxy addresses dario2@contoso.com and dario3@contoso.com, all of the following filters will return that mailbox in the result: "PrimarySmtpAddress -eq 'dario@contoso.com'", "PrimarySmtpAddress -eq 'dario2@contoso.com'", or "PrimarySmtpAddress -eq 'dario3@contoso.com'".
You have to specify email addresses, I was searching for Domains which were set as PrimarySMTPAddress