-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGet-MXReport.ps1
More file actions
29 lines (27 loc) · 787 Bytes
/
Copy pathGet-MXReport.ps1
File metadata and controls
29 lines (27 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$domains = Import-Csv .\domains.txt | Select-Object -ExpandProperty Domain
foreach ($domain in $domains)
{
$resolve = @()
$resolve = Resolve-DnsName $domain -Type MX | Where-Object {$_.QueryType -eq "MX"}
if ($resolve)
{
foreach ($name in $resolve)
{
$Properties = @{
"Domain"=$domain
"MX"=$name.NameExchange
"Preference"=$name.Preference}
$Obj = New-Object -TypeName PSObject -Property $Properties
Write-Output $Obj | Select-Object Domain, MX, Preference
}
}
else
{
$Properties = @{
"Domain"=$domain
"MX"="No MX data"
"Preference"="No MX data"}
$Obj = New-Object -TypeName PSObject -Property $Properties
Write-Output $Obj | Select-Object Domain, MX, Preference
}
}