PowerShell: Perform a DNS Lookup
Need to resolve a domain name to its IP address(es) - for troubleshooting connectivity, verifying DNS configuration, or checking what a domain points to? This one-liner performs the lookup directly from the terminal.
Prerequisites:
- Privileges: None
- Module: Built-in, no import needed
Quick Command:
Resolve-DnsName -Name "google.com"
Example Output:
Name Type TTL Section IPAddress
---- ---- --- ------- ---------
google.com AAAA 300 Answer 2a00:1450:4014:80c::200e
google.com A 300 Answer 172.217.19.14
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.
How It Works:
- Resolve-DnsName performs an active DNS query, sending a request to your configured DNS server (unlike Get-DnsClient/Get-DnsClientServerAddress, which only show local DNS configuration, not actual lookups).
- Type shows the DNS record type returned - A is a standard IPv4 address, AAAA is IPv6.
- TTL (Time To Live) shows how many seconds this result can be cached before it should be looked up again.
- IPAddress is the actual resolved address the domain name points to.