Public/Get-AllegisSPF.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
function Get-AllegisSPF ($DomainName) { if ((get-module -ListAvailable dnsclient) -eq $null){write-error 'missing DnsClient module. unable to continue';break} #Get TXT record that contains "spf" and split the string $SPFResults = (resolve-dnsname -type txt -name $DomainName | ? {$_.strings -like "*spf*"}).strings.split(" ") #Get rid of first and last entries to clean up a bit $SPFResults = ($SPFResults.trim($SPFResults[0])).trim($SPFResults[$SPFResults.count -1]) #Recursive check for include statements in SPF record $SPFResults | % { if ($_ -like "include:*") { $IncludedDomain = $_.split(":")[1] $SPFResults += "Getting SPF for included record: $($IncludedDomain)" $SPFResults += SPF_Lookup $IncludedDomain } } return $SPFResults } |