Trace DNS resolution across configured resolvers
Documentation: Microsoft Learn
The script asks each configured IPv4 DNS server directly. That removes the local resolver cache and server-selection ambiguity from the comparison.
The script
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
$name = 'app.contoso.com'
$servers = (Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses | Sort-Object -Unique
foreach ($server in $servers) {
try {
$answer = Resolve-DnsName -Name $name -Server $server -Type A -ErrorAction Stop
[pscustomobject]@{ Server= $server;Status= 'Resolved';Address=($answer.IPAddress -join ', ') }
}
catch {
[pscustomobject]@{ Server= $server;Status= 'Failed';Address= $null;Error= $_.Exception.Message }
} }- Stage 1$name
Positional values or no named parameters - Stage 2Sort-Object
-Unique
How it works
The script asks each configured IPv4 DNS server directly. That removes the local resolver cache and server-selection ambiguity from the comparison. Failures are captured as data so one dead resolver does not stop the rest of the test.
Adapting it
Change Type to AAAA, SRV or CNAME when the record type matters. Add Resolve-DnsName -DnsOnly when you specifically want to avoid fallback behavior.