Skip to content

Instantly share code, notes, and snippets.

@clemmesserli
Created May 1, 2020 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clemmesserli/fd969e21669d5710edf76cb5686fac89 to your computer and use it in GitHub Desktop.
Save clemmesserli/fd969e21669d5710edf76cb5686fac89 to your computer and use it in GitHub Desktop.
Sample on how you might verify DNS name resolution
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