4

I'm trying to search for SMTP addresses using an LDAPFilter on ADObject

Get-AdObject  -properties * -LDAPFilter "(proxyAddresses=alert.haveibeenpwned@test.edu)" 

I understand that some of this is possible with GetADUser and Get-Mailbox, or even with the -Filter with the -anr command. However for consistency I'd prefer to use native LDAP with the Get-AdObject command.

How can I search a multivalued property, like proxyAddresses using Get-AdObject?

Ran Dom
  • 191
  • 1
  • 3
  • 6

1 Answers1

5
Get-ADObject -Properties * -Filter {ProxyAddresses -eq "smtp:email@yourdomain.com"}
Get-ADObject -Properties * -LDAPFilter "(proxyAddresses=smtp:email@yourdomain.com)"

When filtering on multivalued properties, the filter is satisfied if any of the values matches the search string.

But please note the syntax smtp:email@yourdomain.com; the ProxyAddresses attribute values always have the smtp: prefix (or a different prefix for other address types, like SIP or X400).

Massimo
  • 70,200
  • 57
  • 200
  • 323
  • For @Ran Dom's sake, you can clean up the output by adding " | Select-Object Name,ProxyAddresses" to the end of these commands. – SamErde Jul 19 '18 at 15:49
  • Of course, if you simply need to display it; but maybe you need to do something else with the results :) – Massimo Jul 19 '18 at 19:47
  • 1
    Absolutely agree. Just adding that tip in case he had a follow-up question about the output. – SamErde Jul 19 '18 at 20:26