Monday, December 19, 2022

Finding Mailbox With a Specific Proxy Address

 Hello everyone!

I recently got a request to find a mailbox that is using a specific proxy address.  I have been working for my company for over 3 years and I found it interesting we haven't been ask to do this sooner.  It is requests like this that shows the usefulness of PowerShell.

The first script that was created just checked Active Directory for the proxy address:
Get-ADUser -Filter * -Properties proxyaddresses | Select -Object Name,@{L="ProxyAddresses";E={($_.ProxyAddresses -match '^smtp:')}} | fl

You will get the following output:





Since I believe in the concept of "complete work", I changed the script to search Exchange Online for the proxy addresses.  Connect to MSOL and use the following:
Get-MSOLUser -all | Select-Object UserPrincipalName,,@{L="ProxyAddresses";E={($_.ProxyAddresses -match '^smtp:')}} | fl

This will give you the same output format as the first script.

For both scripts, you can substitute "-match '^smtp:'" for something more specific.  For example, if you want to search for proxy addresses that start with "HR', you can change the script as follows:
Select-object Name,@{L="ProxyAddresses";E={($_.ProxyAddress -match '^smtp:hr*')}}I

As always, I hope you found this information useful.  Please feel free to post a comment or question.

Until next time...


2 comments:

  1. hello, thanks for the sharing. What is the behavior of EXO when a user have a blank proxyaddress ?

    ReplyDelete
  2. I believe it returns an empty list

    ReplyDelete