Resolve-DnsName
Use Resolve-DnsName to query DNS for a name or address and return the records, bypassing the local cache when asked.
Documentation: Microsoft Learn — PowerShell module reference
Syntax
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Resolve-DnsName [-Name] <String> [[-Type] <recordtype>] [-Server <String[]>] [-DnsOnly] [-NoHostsFile] [-CacheOnly] [-DnssecOk] [<CommonParameters>]- Stage 1Resolve-DnsName
-Name -Type -Server -DnsOnly -NoHostsFile -CacheOnly -DnssecOk
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Resolve-DnsName -Name powershellgenie.com
Show reference output
Sample output · fictional data, shaped like the real thing
Name Type TTL Section IPAddress ---- ---- --- ------- --------- -Name A 300 Answer 10.20.30.11
Resolve-DnsName -Name powershellgenie.com (2)
Show reference output
Sample output · fictional data, shaped like the real thing
Name Type TTL Section IPAddress ---- ---- --- ------- --------- -Name A 300 Answer 10.20.30.11
Resolve-DnsName -Name powershellgenie.com (3)
Show reference output
Sample output · fictional data, shaped like the real thing
Name Type TTL Section IPAddress ---- ---- --- ------- --------- -Name A 300 Answer 10.20.30.11
Parameters
Parameter definitions:
-Name-Type-Server-DnsOnly-NoHostsFile-CacheOnly-DnssecOk
Practical use and troubleshooting
Practical scenario: Use Resolve-DnsName when you need to query DNS for a name or address and return the records, bypassing the local cache when asked. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: NXDOMAIN means the queried name was not found by the DNS path used. Check the exact name, suffix and selected server, then distinguish missing records from transport timeouts. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Test-NetConnection. Resolve-DnsName tests DNS resolution; Test-NetConnection can test a TCP port. A correctly resolved hostname does not prove that the application is reachable. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Recap
Resolve-DnsName Use Resolve-DnsName to query DNS for a name or address and return the records, bypassing the local cache when asked.
Next: Resolve-Path