Created
May 1, 2020 04:23
-
-
Save clemmesserli/fd969e21669d5710edf76cb5686fac89 to your computer and use it in GitHub Desktop.
Sample on how you might verify DNS name resolution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cls | |
Clear-DnsClientCache | |
$NameServers = @( | |
"8.8.8.8", | |
"8.8.4.4", | |
"208.67.222.222", | |
"1.1.1.1" | |
) | |
$HostNames = @( | |
"google.com", | |
"yahoo.com" | |
) | |
$dnsInfo = [System.Collections.Generic.List[PSObject]]::New() | |
foreach ($NameServer in $NameServers) { | |
foreach ($hostName in $HostNames) { | |
$dnsName = Resolve-DnsName -Name $hostName -Type A -Server $NameServer | |
$dnsInfo.add( | |
[pscustomobject]@{ | |
Name = $dnsName.Name.ToLower() -join "," | |
Type = $dnsName.Type -join "," | |
IPv4Address = $dnsName.ip4Address -join "," | |
TTL = $dnsName.TTL | |
NameServer = $NameServer | |
} | |
) | |
} | |
} | |
$dnsInfo | Sort-Object Name, NameServer | ft –AutoSize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment