diff --git a/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordDkim.ps1 b/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordDkim.ps1 index c899fa28..8116521e 100644 --- a/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordDkim.ps1 +++ b/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordDkim.ps1 @@ -104,7 +104,7 @@ Function ConvertFrom-MailAuthenticationRecordDkim { NameServer = $dkimSplat.Server ErrorAction = $dkimSplat.ErrorAction } - $dkimRecord = [SPFRecord]::new((Resolve-Dns @dkimSplatAlt | ` + $dkimRecord = [SPFRecord]::new(((Resolve-Dns @dkimSplatAlt).Answers | ` Where-Object {$_.RecordType -eq "TXT"} | ` Where-Object {$_.Text -imatch $matchRecord}).Text) }else{ diff --git a/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordDmarc.ps1 b/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordDmarc.ps1 index 3a22e5c4..b9212735 100644 --- a/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordDmarc.ps1 +++ b/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordDmarc.ps1 @@ -235,7 +235,7 @@ Function ConvertFrom-MailAuthenticationRecordDmarc { NameServer = $dmarcSplat.Server ErrorAction = $dmarcSplat.ErrorAction } - $dmarcRecord = [DMARCRecord]::new((Resolve-Dns @dmarcSplatAlt | ` + $dmarcRecord = [DMARCRecord]::new(((Resolve-Dns @dmarcSplatAlt).Answers | ` Where-Object {$_.RecordType -eq "TXT"} | ` Where-Object {$_.Text -imatch $matchRecord}).Text) }else{ diff --git a/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordMx.ps1 b/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordMx.ps1 index 7b7f3c43..c3f5fc20 100644 --- a/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordMx.ps1 +++ b/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordMx.ps1 @@ -16,7 +16,7 @@ microsoft.com MX 1731 Answer microsoft-com.m Function ConvertFrom-MailAuthenticationRecordMx { [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Colors are beautiful')] - [OutputType([Microsoft.DnsClient.Commands.DnsRecord_MX],[System.String])] + [OutputType([PSCustomObject],[System.String])] [cmdletbinding()] param( [Parameter(Mandatory)] @@ -41,23 +41,26 @@ Function ConvertFrom-MailAuthenticationRecordMx { try{ if($isWindows){ $mxRecords = Resolve-DnsName @mxSplat | Where-Object {$_.Type -eq "MX"} + $mxRecords = $mxRecords|ConvertTo-Json|ConvertFrom-Json }else{ + Write-Verbose "Is not Windows, checking for Resolve-Dns" $cmdletCheck = Get-Command "Resolve-Dns" if($cmdletCheck){ + Write-Verbose "Resolve-Dns exists, querying records" $mxSplatAlt = @{ Query = $mxSplat.Name QueryType = $mxSplat.Type NameServer = $mxSplat.Server ErrorAction = $mxSplat.ErrorAction } - $answers = (Resolve-Dns @mxSplatAlt | Where-Object {$_.RecordType -eq "MX"}).Answers + $answers = (Resolve-Dns @mxSplatAlt).Answers | Where-Object {$_.RecordType -eq "MX"} $mxRecords = $answers | ForEach-Object { [PSCustomObject]@{ - Name = $_.DomainName + Name = $_.DomainName NameExchange = $_.Exchange - Type = $_.RecordType - TTL = $_.TimeToLive - Preference = $_.Preference + Type = $_.RecordType + TTL = $_.TimeToLive + Preference = $_.Preference } } }else{ diff --git a/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordSpf.ps1 b/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordSpf.ps1 index 4a93659c..f57021dc 100644 --- a/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordSpf.ps1 +++ b/powershell/public/CISA/exchange/ConvertFrom-MailAuthenticationRecordSpf.ps1 @@ -137,7 +137,7 @@ Function ConvertFrom-MailAuthenticationRecordSpf { NameServer = $spfSplat.Server ErrorAction = $spfSplat.ErrorAction } - $spfRecord = [SPFRecord]::new((Resolve-Dns @spfSplatAlt | ` + $spfRecord = [SPFRecord]::new(((Resolve-Dns @spfSplatAlt).Answers | ` Where-Object {$_.RecordType -eq "TXT"} | ` Where-Object {$_.Text -imatch $matchRecord}).Text) }else{