View Code? Open in Web Editor
NEW
A PowerShell module to verify that your Office 365 DNS records have been set up correctly.
Home Page: https://powershellgallery.com/packages/Office365DnsChecker
License: GNU General Public License v3.0
office365dnschecker's Issues
Would be great if this module also returned objects, so we can easily build upon it. Like, when testing SPF, if it could return "Enabled" equals $true or $false, and similar.
Using Google DNS API for looking up DNS records might help speed up the code, plus it will truly be multi platform.
Example
# # Domain
$Domain = ' <some_domain>'
# # Uri
# ## All
$Uri = ' https://dns.google.com/resolve?name={0}&type=all' -f $Domain
# ## A
$Uri = ' https://dns.google.com/resolve?name={0}&type=a' -f $Domain
# ## MX
$Uri = ' https://dns.google.com/resolve?name={0}&type=mx' -f $Domain
# ## TXT
$Uri = ' https://dns.google.com/resolve?name={0}&type=txt' -f $Domain
# # Request
(Invoke-RestMethod - Uri $URI - Method ' Get' ).' Answer'
# # AIO SPF
([array ]((Invoke-RestMethod - Uri (' https://dns.google.com/resolve?name={0}&type=txt' -f $Domain ) - Method ' Get' ).' Answer' .Where{$_ .' data' -like ' "v=spf1*' })).' Count' -gt 0