So you’re working on getting all of your email domains that’s on-prem into Azure or you simply want to ensure that your on-prem Exchange has been configured for all the domains your user accounts utilize. Your Active Directory domain contains over 30,000 accounts. How would you go about discovering the unique email domains?
Knowing that the Active Directory attribute proxyAddresses contains the account’s SMTP addresses, we can start there. Also, you only want to include only those domains for active accounts. [Note: The proxyAddresses also contains other address types, but we are only concerned about SMTP for this exercise.]
First, let’s get all the proxyAddresses into a variable.
|
|
Next, we will loop through each one, matching on only SMTP addresses. We split on the @ symbol and return the domain portion.
|
|
Finally, we use Sort-Object -Unique to get the unique domains.
|
|
Of course, you could have dozens or more unique domains. This short exercise can also reveal typos in domains.
Hopefully, this post was helpful to you in some way.
Have a great day!