Public/Email/Get-MXRecord.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Get-MXRecord { <# .SYNOPSIS Gets MX records for the requested domain(s). .DESCRIPTION Gets MX records for the requested domain(s). .PARAMETER Domain The domain(s) to get the MX records of. .EXAMPLE Get-MXRecord 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 MX Records" -Status "Getting MX Records for [$Entry]" -ID 309172452 $CurrentCount++ $MXRecord = Resolve-DNSName -Type MX -Name $Entry | Where-Object { $_.Type -eq "MX" } FOREACH ($Item in $MXRecord) { $Results += [PSCustomObject]@{ PSTypeName = 'IntegrisPowerShell.DNSRecord' Domain = $Entry Name = $Item.Name Type = $Item.Type Purpose = "MX" Value = $Item.NameExchange Preference = $Item.Preference } } } $Results = $Results | Sort-Object Domain Write-IntegrisLogFile $Results Write-Progress -ID 309172452 -Completed -Activity "Getting MX Records" RETURN $Results } |