COMMAND

Resolve-DnsNameQuery DNS in PowerShell

Resolve-DnsName is the PowerShell cmdlet for DNS queries. It returns structured objects instead of nslookup's text, so results are easy to filter and script. -Type selects the record type, -Server queries a specific resolver, and -DnsOnly or -TcpOnly control how the query is made.

BlackhawkHub Editorial · Updated

Purpose

Resolve-DnsName performs DNS lookups and returns each record as an object. That makes it the better choice for scripting and for precise queries, complementing the interactive nslookup.

Basic queries

powershell
Resolve-DnsName example.com
Resolve-DnsName example.com -Type MX
Resolve-DnsName example.com -Type TXT
Resolve-DnsName example.com -Type AAAA

Output is a table of records with their type, TTL and data, which you can pipe:

powershell
Resolve-DnsName example.com -Type MX | Sort-Object Preference |
  Select-Object NameExchange, Preference

Target a specific server

powershell
Resolve-DnsName example.com -Server 1.1.1.1 -DnsOnly
Resolve-DnsName example.com -Server 8.8.8.8 -DnsOnly

Comparing resolvers is how you diagnose DNS propagation: if a public resolver has the new record and your default does not, the local resolver is stale.

Force TCP or check DNSSEC

powershell
Resolve-DnsName example.com -TcpOnly
Resolve-DnsName example.com -DnssecOk

-TcpOnly confirms TCP port 53 works (some large responses need it); -DnssecOk requests DNSSEC records.

Reverse lookup

powershell
Resolve-DnsName 93.184.215.14

Returns the PTR record if one exists.

Common mistakes

  • Forgetting -DnsOnly, so Windows may answer from LLMNR or the hosts file instead of DNS, masking a real DNS problem.
  • Not specifying -Type when you need MX, TXT or NS; the default returns address records only.
  • Expecting it on non-Windows PowerShell without the DnsClient module; it is a Windows cmdlet.

Frequently asked questions

Resolve-DnsName vs nslookup?

Both query DNS. Resolve-DnsName returns objects you can filter, sort and export, which suits scripting; nslookup prints text and has an interactive mode. For a quick manual check either works; for automation prefer Resolve-DnsName.

How do I query a specific DNS server?

Resolve-DnsName example.com -Server 1.1.1.1 -DnsOnly. -DnsOnly skips LLMNR and NetBIOS so you test DNS alone; -Server picks the resolver, which isolates a broken local resolver from a broken record.

Sources