PowerShell Genie

PowerShell DNS troubleshooting

Compare the same DNS question across the resolution paths your application actually uses.

Lesson 2 min read Windows PowerShell 5.1 and PowerShell 7

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
  1. Stage 1[pscustomobject]@{Positional values or no named parameters
  2. Stage 2Format-ListPositional 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-List

    What 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

    Microsoft Learn: resolve-dnsname

    Try it

    Expected output · prints command text; does not execute these commands

    1PS> [pscustomobject]@{
    2PS> Check1 = 'Resolve-DnsName www.example.com -Type A'
    3PS> Check2 = 'Resolve-DnsName www.example.com -Server 8.8.8.8'
    4PS> Check3 = 'Clear-DnsClientCache'
    5PS> Check4 = 'Get-DnsClientServerAddress'
    6PS> } | Format-List

    Example reader

    Inspect this page's example

    Fictional browser data when supported

    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 administration

      Check your understanding

      A name resolves against one DNS server but fails against another. What do you compare?

      Genie guidePowerShell DNS troubleshooting

      Compare the same DNS question across the resolution paths your application actually uses.