Skip to content

Instantly share code, notes, and snippets.

@adamhancock
Last active August 20, 2019 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamhancock/0cf0b12be0d9ff732d30082430aa89ea to your computer and use it in GitHub Desktop.
Save adamhancock/0cf0b12be0d9ff732d30082430aa89ea to your computer and use it in GitHub Desktop.
# Adam Hancock
if(Get-Module MSOnline){
write-host "Module already installed."
}else{
Install-Module -Force MSOnline
}
if(!$Cred){
$Cred = Get-Credential
}
Connect-MsolService -Credential $Cred
$customers= Get-MsolPartnerContract -All
Write-Host "Found $($customers.Count) customers for this Partner."
write-host "Checking SPF Records..."
foreach ($customer in $customers) {
$domains= Get-MsolDomain -TenantId $customer.TenantId | Where {$_.IsInitial -eq $false}
foreach($domain in $domains){
if($domain.name -like "*.smtp.exclaimer.cloud"){
continue
}
$spf = resolve-dnsname $domain.name -type TXT -ErrorAction silentlycontinue | Where-Object Strings -Match "spf1"
if(!$spf){
write-host -ForegroundColor Red "$($customer.name) - $($domain.name) - missing SPF"
}else{
if($spf.Strings -contains "v=spf1" -AND $spf.Strings -notcontains "include:spf.protection.outlook.com"){
write-host -ForegroundColor Yellow "$($domain.name) - missing Office 365 from SPF"
}
}
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment