Public/Email/Get-DMARCRecord.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Get-DMARCRecord { <# .SYNOPSIS Gets DMARC records for the requested domain(s). .DESCRIPTION Gets DMARC records for the requested domain(s). .PARAMETER Domain The domain(s) to get the DMARC record of. .EXAMPLE Get-DMARCRecord IntegrisIt.com,Microsoft.com #> [CmdletBinding()] param ( [Parameter(Mandatory)] [STRING[]]$Domain ) $Results = @() $TotalCount = $Domain.Count $CurrentCount = 0 FOREACH ($Entry in $Domain) { Write-IntegrisProgressBar -TotalCount $TotalCount -CurrentCount $CurrentCount -Activity "Getting DMARC Records" -Status "Getting DMARC Record for [$Entry]" -ID 179182452 $CurrentCount++ $DMARCRecord = Resolve-DNSName -Type TXT -Name $Entry | Where-Object { $_.Strings -like "*v=DMARC1*" } IF ($null -eq $DMARCRecord) { $DMARCRecord = (Resolve-DNSName -Type TXT -Name "_DMARC.$Entry" -ErrorAction SilentlyContinue | Where-Object { $_.Strings -like "*v=DMARC1*" }) } FOREACH ($Item in $DMARCRecord) { $Results += [PSCustomObject]@{ PSTypeName = 'IntegrisPowerShell.DNSRecord' Domain = $Entry Name = $Item.Name Type = $Item.Type Purpose = "DMARC" Value = $Item.Strings Preference = "" } } } Write-IntegrisLogFile $Results Write-Progress -ID 179182452 -Completed -Activity "Getting DMARC Records" RETURN $Results } |