SPF Item IP in EFD Count
-------- ---------------
67.231.157.188 119
67.231.149.193 118
67.231.149.193 118 *Duplicate*
67.231.149.193 118 *Duplicate*
170.48.2.165 0
170.48.2.165 0 *Duplicate*
170.48.2.165 0 *Duplicate*
185.132.180.109 44
185.183.28.71 40
#Import all CSVs $spflist = Import-Csv -Path "C:\psscripts\input\SPF.csv" -Delimiter : -Header Mechanism, Value $EFDLast30Days = import-csv -path "C:\psscripts\input\CignaSendingIPs.csv" | Select Sender, IPAddress #Import module used to validate IP addresses Import-Module -Name "C:\psscripts\validate-ip.psm1" $spfitem = @() # Determine SPF Mechanism in use: ip4:(address or CIDR),ip6, or domain (include:) foreach ($spfitem in $spflist) { # Select lines in SPF that start with ip4 if ($spfitem.Mechanism -like "ip4") { [string]$spfip4 = $spfitem.Value # Determine if ip4 value is IP address or CIDR $check = confirm-ipv4 -ipaddress $spfip4 if ($check -eq "True") { $isIPfound = $spfip4 # If "True" then value is regular IPv4 address # $spfIPfoundinEFD = ($EFDLast30Days.IPAddress).Where( { $_ -like "*$isIPfound*" }) | Measure-Object $itemcount = ($findip = Select-String -Pattern $isIPfound -Path "C:\psscripts\input\CignaSendingIPs.csv" -AllMatches).Matches.Value $ipcount = $itemcount.count } $columns = New-Object -TypeName PSObject -Property @{"SPF Item" = $isIPfound"IP in EFD Count" = $ipcount } } $columns }