Skip to content

Commit

Permalink
Merge pull request #317 from Snozzberries/ExoDns
Browse files Browse the repository at this point in the history
Fix to property reference on conversion functions
  • Loading branch information
merill authored Jul 11, 2024
2 parents b625b6d + 5cd6fb9 commit dea7912
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit dea7912

Please sign in to comment.