Compare DNS answers across servers
Documentation: Microsoft Learn
The loop asks each server in $DnsServers to resolve $Name and stamps the responding server onto every record with a calculated property.
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 = "example.com"
$DnsServers = "DC01", "DC02"
foreach($Server in $DnsServers){ Resolve-DnsName $Name -Server $Server | Select-Object @{ Name = "Server"; Expression = { $Server } },Name,Type,IPAddress }- Stage 1$Name
Positional values or no named parameters
How it works
The loop asks each server in $DnsServers to resolve $Name and stamps the responding server onto every record with a calculated property. Name, Type, and IPAddress come straight from the response, so identical answers appear as identical rows and a divergence stands out immediately.
Adapting it
Add -Type to the Resolve-DnsName call when the record in question is not an address record, and pass -DnsOnly so the local resolver cache stays out of the comparison.
If the result is unexpected
DNS servers return different answers for the same name.
Split DNS, cache state, record type and replication can make answers differ legitimately.
- Query the same fully qualified name and record type against each named server.
Validate the result
Each answer is tied to its responding server, record type and observation time.
Keep the check reliable
Define the expected DNS view before treating every answer difference as a fault.