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.
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
Resolve-DnsName example.com
Resolve-DnsName example.com -Type MX
Resolve-DnsName example.com -Type TXT
Resolve-DnsName example.com -Type AAAAOutput is a table of records with their type, TTL and data, which you can pipe:
Resolve-DnsName example.com -Type MX | Sort-Object Preference |
Select-Object NameExchange, PreferenceTarget a specific server
Resolve-DnsName example.com -Server 1.1.1.1 -DnsOnly
Resolve-DnsName example.com -Server 8.8.8.8 -DnsOnlyComparing 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
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
Resolve-DnsName 93.184.215.14Returns 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
-Typewhen 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.