Resolve DnsName - PowerShell


The Resolve-DnsName command is a powerful tool in PowerShell that enables users to resolve DNS names and obtain DNS record information. It performs DNS lookups and returns detailed records about the target domain or host. This command is particularly useful for network administrators, system engineers, and anyone who needs to troubleshoot DNS-related issues or manage DNS configurations.


Resolve-DnsName [-Name] <string[]> [-Type <string[]>] [-Server <string[]>] [-Zone <string[]>] [-Refresh] [-Cache] [-ErrorAction <ActionPreference>] [-ErrorVariable <string>] [-OutBuffer <int>] [-OutVariable <string>] [<CommonParameters>]


  • -Name: Accepts a hostname or domain name to resolve.
  • -Type: Specifies the type of DNS record to resolve (e.g., A, AAAA, MX, CNAME).
  • -Server: Used to specify the DNS server to query.
  • -Zone: Filters the results to only include records from a specific DNS zone.
  • -Refresh: Refreshes DNS cache before performing the lookup.
  • -Cache: Forces the command to use cached records, if available.
  • -ErrorAction: Specifies the action to take when an error occurs.
  • -ErrorVariable: Stores any errors encountered during execution in the specified variable.
  • -OutBuffer: Controls the number of objects to buffer.
  • -OutVariable: Assigns the output to a specified variable.


Simple Lookup:

Resolve-DnsName -Name

Lookup by Record Type:

Resolve-DnsName -Name -Type A

Custom DNS Server:

Resolve-DnsName -Name -Server

Specific DNS Zone:

Resolve-DnsName -Name company.local -Zone dc1.local

Refresh DNS Cache:

Resolve-DnsName -Name -Refresh

Common Issues

  • Ensure the specified DNS server is reachable and responding.
  • Verify that the hostname or domain name is spelled correctly.
  • Check the DNS record type (e.g., A, AAAA) matches the desired record.
  • Consider disabling the DNS cache using -Cache $false if cached results are outdated.


PowerShell Scripting:

$dnsRecords = Resolve-DnsName -Name ""
foreach ($record in $dnsRecords) { Write-Host $record }

Integrating with Other Tools:

$dnsRecords = Resolve-DnsName -Name ""
Get-DnsServerResourceRecord -Zone | Where {$_.Name -in $dnsRecords.Name}
  • Get-DnsClient
  • Set-DnsClientServerAddress
  • Remove-DnsClientServerAddress
  • Enable-DnsSEC
  • Disable-DnsSEC