Checking if a domain’s mail server is actually Gmail using Powershell

Firstly, run powershell as Administrator and execute

Import-Module DnsClient

After that you can run the Resolve-DnsName cmdlet:


Which returns:

You can specify which type of record you’re interested in:

Resolve-DnsName -type MX


So, take that logic and add a sprinkle of basic string functions to get:

(-join (Resolve-DnsName -Type MX –Name -ea 0).NameExchange).ToLowerInvariant().Contains("google")

Which returns True/False if any of the MX records contain “google”, which would mean the mail server is Gmail.

Leave a Reply

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