Query DNS records with Resolve-DnsName in PowerShell
The modern, scriptable replacement for nslookup: ask for exact record types, hit specific DNS servers, and see TTLs as objects.
01Command
$ Resolve-DnsName mail.example.com -Type MX02What it does
nslookup is legacy and truncates output; Resolve-DnsName returns typed objects — A records, CNAME chains, MX preferences, TXT strings — that you can filter in PowerShell. `-Server` lets you compare answers between your ISP resolver and a public one, which is how you diagnose split-brain DNS or propagation. `-DnsOnly` skips local cache and hosts-file entries so you see what servers actually answer.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Resolve-DnsName - PowerShellEvidence: SS64 shows Resolve-DnsName performing DNS name resolution with -Type and -Server options, the PowerShell equivalent of nslookup/dig.
- Resolve-DnsName | Microsoft LearnEvidence: Microsoft documents Resolve-DnsName's -Type parameter accepting record types like MX and TXT, and -Server to query a specific DNS server.
Last verified: 2026-09-17 · Category: Network
06Related solutions
Purge cached DNS lookups so Windows re-resolves hostnames from scratch — the fix for 'the new server is live but my browser still hits the old one'.
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.
The PowerShell-native replacement for netstat: filter connections by state, port, or process and pipe results instead of parsing text.