Public/Utilities/Confirm-SPF.ps1
function Confirm-SPF () { Param( [Parameter(Mandatory)] [string]$DomainName ) try { $SPFRecord = (Resolve-DnsName -Name $DomainName -Type TXT).Strings | Where-Object { $_ -like 'v=spf1*' } } catch { Write-Error "Failed to resolve SPF record for $($DomainName): $_" } Write-Host "Current SPF record for $($DomainName):" -ForegroundColor Yellow Write-Host $SPFRecord Write-Host "Validating SPF record.." -ForegroundColor Yellow $FormBody = @{ domain = $DomainName serial = "fred12" } $Request = Invoke-WebRequest -Uri "https://www.kitterman.com/spf/getspf3.py" -Method Post -Body $FormBody if($Request.Content -like "*SPF record passed validation test*") { Write-Host "The SPF record is valid." -ForegroundColor Green } else { $Result = $Request.Content.Split('Results - ')[1].Split(' </p>')[0] Write-Host "The SPF record is invalid: $($Result)" -ForegroundColor Red } } |