PowerShell Get-DnsClient
last modified February 15, 2025
In this article, we will cover the Get-DnsClient
cmdlet in
PowerShell. This cmdlet retrieves DNS client configuration information.
It helps manage and troubleshoot network name resolution settings.
DNS Client basics
The DNS client service resolves hostnames to IP addresses. It caches recent
lookups to improve performance. The Get-DnsClient
cmdlet shows
current DNS settings. This includes server addresses, cache contents, and
interface-specific configurations.
Basic Get-DnsClient usage
The simplest way to use Get-DnsClient
is without parameters.
This shows DNS client settings for all network interfaces. The output includes
server addresses and interface indexes. Each interface has its own DNS config.
Get-DnsClient
This command retrieves DNS client settings for all interfaces. The output shows server addresses and interface details. Multiple entries appear for systems with several network adapters.
Get DNS server addresses
To view only the DNS servers configured for name resolution, use the
ServerAddresses
property. This shows the IP addresses of all
DNS servers used by the system. The list includes both IPv4 and IPv6 addresses.
Get-DnsClientServerAddress
This command returns all configured DNS server addresses. The output is organized by network interface. Each interface may have different DNS servers.
PS C:\> .\dns2.ps1 InterfaceAlias Interface Address ServerAddresses Index Family -------------- --------- ------- --------------- Ethernet 12 IPv4 {192.168.1.1, 8.8.8.8} Wi-Fi 7 IPv4 {192.168.1.1} Ethernet 12 IPv6 {fec0:0:0:ffff::1}
Get DNS cache entries
The DNS client caches recent name resolutions to improve performance. Use
Get-DnsClientCache
to view these cached entries. The cache
includes hostnames, record types, and TTL values. This helps troubleshoot
name resolution issues.
Get-DnsClientCache
This command displays all cached DNS records. The output shows hostnames, record types, and expiration times. The cache refreshes automatically as entries expire.
Get DNS settings for specific interface
To view DNS settings for a particular network interface, use the
-InterfaceIndex
parameter. First identify the interface index
with Get-NetAdapter
. Then filter DNS settings for that interface.
Get-DnsClient -InterfaceIndex 12
This command shows DNS client settings for interface index 12. The output includes server addresses and other interface-specific configurations.
Check DNS suffix settings
DNS suffixes are used for incomplete hostname resolution. Use
Get-DnsClientGlobalSetting
to view suffix configurations.
This shows the suffix search list and other global DNS client settings.
Get-DnsClientGlobalSetting
This command returns global DNS client settings. The output includes the suffix search list and connection-specific suffix settings. These affect how incomplete hostnames are resolved.
Source
In this article, we have covered the Get-DnsClient cmdlet in PowerShell.
Author
List all PowerShell tutorials.