Forum Discussion
Asbjørn Vang Jacobsen
Jun 19, 2018Copper Contributor
How can I query Exchange Online for the generated MX record for each of my domains?
Is it possible to read the generated MX record for each Email domain in Exchange Online anywhere except on the Admin Portal? For example in Powershell?
More specifically I am talking about the MX record that I'm supposed to set on my domain in order to be able to receive email.
I can see it on the Admin Portal, but I want to be able to query it somehow.
The reason for this is that I need to be able to make a monitoring service for the several hundred MX records for my customers' domains.
So far, I've been able to list all the domains of all my Tenants with the Powershell MSOnline Module, but I can't find the value of the MX record for the domain anywhere in the Powershell module's commands.
I tried predicting the MX record which is generated from these set of rules...I think....
Example:
Domain: contoso.com
Random String: 01c
1. Domain Name's . (dot) is replaced by - (dash) resulting in contoso-com.
2. If contoso-com unique indentifier has already been taken for some reason, add some random string in the end, so the MX will be unique.
3. Add .mail.protection.outlook.com.
This will result in either contoso-com.mail.protection.outlook.com. if the random string is not used,
or it will result in contoso-com01c.mail.protection.outlook.com.
So you see my problem here. I cannot predict the MX record. I need to be able to read this value in order to create reliable monitors.
And I can't log onto every single customer and write down each and every MX record, primarily because I'm a programmer, and I'm a programmer primarily because I'm lazy. There I've said it. ;)
Yes, it's possible via the AzureAD module:
Get-AzureADDomainServiceConfigurationRecord -Name domain.com | ? {$_.RecordType -eq "Mx"} | select MailExchange
Yes, it's possible via the AzureAD module:
Get-AzureADDomainServiceConfigurationRecord -Name domain.com | ? {$_.RecordType -eq "Mx"} | select MailExchange
- my183Copper Contributor
It works on some domains but does not on most of them. Out of 39 domains worked just in 3 cases.
Any idea why? Thanks,
- Asbjørn Vang JacobsenCopper Contributor
That was exactly what I was looking for. Thank you.