Find Mail Domain Used Exchange

Find Mail Domain Used Exchange

Hello,

All Exchange and Skype addresses for each user are stored in Active Directory. All those information are stored in the “ProxyAddresses” attribute. This is a multi-valued attribute with one address per line. Each of them are prefixed with:

  • SMTP : Primary SMTP address.
  • smtp : Secondary SMTP address.
  • SIP : Skype/Lync address.
  • x500 : Exchange legacy DistinguishedName.

So, you just need to grab all “ProxyAddress” on all Active Directory account, then parse them to extract the domain, and then, you get all the DNS domain used in PrimarySMTP, SecondarySMTP and SIP addresses.

Find Mail Domain Used Exchange – Primary SMTP

This line will go through each AD user account, get the ProxyAddresses attribute, filter out the SMTP ones, and extract the domain name fo each, and count them. The use of the operator “-clike” force the “-like” to be case sensitive so it will only extract primary SMTP addresses.

Get-ADUser -Filter * -Properties proxyaddresses | Select-Object -ExpandProperty ProxyAddresses | Where-Object -FilterScript  {$_ -clike 'SMTP:*'} | Select-Object @{Label='ProxyAddresses';Expression={($_ -split '@')[-1]}} | Group-Object -NoElement -Property ProxyAddresses
Find Mail Domain Used Exchange - Primary SMTP

Find Mail Domain Used Exchange – Primary SMTP

Find Mail Domain Used Exchange – Secondary SMTP

Get-ADUser -Filter * -Properties proxyaddresses | Select-Object -ExpandProperty ProxyAddresses | Where-Object -FilterScript  {$_ -clike 'smtp:*'} | Select-Object @{Label='ProxyAddresses';Expression={($_ -split '@')[-1]}} | Group-Object -NoElement -Property ProxyAddresses
Find Mail Domain Used Exchange - Secondary SMTP

Find Mail Domain Used Exchange – Secondary SMTP

Find Mail Domain Used Exchange – SIP

Get-ADUser -Filter * -Properties proxyaddresses | Select-Object -ExpandProperty ProxyAddresses | Where-Object -FilterScript  {$_ -like 'sip:*'} | Select-Object @{Label='ProxyAddresses';Expression={($_ -split '@')[-1]}} | Group-Object -NoElement -Property ProxyAddresses
Find Mail Domain Used Exchange - SIP

Find Mail Domain Used Exchange – SIP

Note : SIP address is unique, you can have SIP aliases.

Conclusion

Those three lines will help you identify which DNS domain are used in your environment. This will work with all version of Exchange, Skype/Lync, even with Office 365 (Exchange Online & Skype Online).

Note : If you are planning an hybrid migration to Office 365, you need to add each domain in your tenant, otherwise, migration will fail

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.