PowerShell Get-DnsClient tutorial shows how to use PowerShell to manage and monitor DNS client settings.
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.
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.
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.
dns1.ps1
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.
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.
dns2.ps1
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}
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.
dns3.ps1
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.
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.
dns4.ps1
Get-DnsClient -InterfaceIndex 12
This command shows DNS client settings for interface index 12. The output includes server addresses and other interface-specific configurations.
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.
dns5.ps1
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.
In this article, we have covered the Get-DnsClient cmdlet in PowerShell.
My name is Jan Bodnar, and I am a passionate programmer with extensive programming experience. I have been writing programming articles since 2007. To date, I have authored over 1,400 articles and 8 e-books. I possess more than ten years of experience in teaching programming.
List all PowerShell tutorials.