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
Using Google DNS API for looking up DNS records might help speed up the code, plus it will truly be multi platform.
Example