PowerShell DNS troubleshooting
Compare the same DNS question across the resolution paths your application actually uses.
Documentation: Microsoft Learn
Overview
Start with the affected client’s resolver configuration and the exact name and record type the application requests. Query each intended resolver directly. A timeout, NXDOMAIN and an unexpected address are different observations and call for different checks.
A public resolver is not a universal baseline. Internal zones and split DNS can intentionally return different answers, or no public answer at all. Compare against the authoritative source and design for the name you are investigating.
Record the answer, responding server and TTL before changing caches. Check authoritative records, forwarding and replication when servers disagree. Cache clearing may help test a corrected configuration, but it does not repair wrong authoritative data.
For AD discovery, inspect the relevant SRV records as well as host records. Successful resolution of a server’s A record does not establish that clients can discover the domain service they need.
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.
[pscustomobject]@{
Check1 = 'Resolve-DnsName www.example.com -Type A'
Check2 = 'Resolve-DnsName www.example.com -Server 8.8.8.8'
Check3 = 'Clear-DnsClientCache'
Check4 = 'Get-DnsClientServerAddress'
} | Format-List- Stage 1[pscustomobject]@{
Positional values or no named parameters - Stage 2Format-List
Positional values or no named parameters
An example to inspect
Preview the example. Sign in for the full lesson and activities.
[pscustomobject]@{
Check1 = 'Resolve-DnsName www.example.com -Type A'
Check2 = 'Resolve-DnsName www.example.com -Server 8.8.8.8'
Check3 = 'Clear-DnsClientCache'
Check4 = 'Get-DnsClientServerAddress'
} | Format-ListWhat happens
The example prints possible diagnostic commands. Choose the resolver appropriate to your zone before using them in a real environment. A disagreement is evidence to explain, not proof that the internal resolver is wrong.
Worth remembering
After the correction, repeat the same name/type query from the affected client and test the application operation.
Primary documentation
Try it
Expected output · prints command text; does not execute these commands
Example reader
Inspect this page's example
Run supported commands against the practice data, or inspect the example without executing it.
Ready to inspect.
Prints the four DNS checks in the order to run them.
Show reference output
Expected output · prints command text; does not execute these commands
Check1 : Resolve-DnsName www.example.com -Type A Check2 : Resolve-DnsName www.example.com -Server 8.8.8.8 Check3 : Clear-DnsClientCache Check4 : Get-DnsClientServerAddress
Keep going
Next: PowerShell Firewall administrationCheck your understanding
A name resolves against one DNS server but fails against another. What do you compare?
Query the same name and record type against each server. Compare responses, zones, forwarding paths and caches before changing client settings.