Export DNS client configuration
Documentation: Microsoft Learn
List configured IPv4 DNS servers with Get-DnsClientServerAddress. Pair each interface with its resolver addresses and exclude empty lists.
The script
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-DnsClientServerAddress -AddressFamily IPv4 | Where-Object ServerAddresses | Select-Object InterfaceAlias,ServerAddresses- Stage 1Get-DnsClientServerAddress
-AddressFamily - Stage 2Where-Object
Positional values or no named parameters - Stage 3Select-Object
Positional values or no named parameters
How it works
Get-DnsClientServerAddress limited to IPv4 returns the configured resolvers per interface, Where-Object drops interfaces with an empty list, and the projection pairs the interface alias with its ServerAddresses collection.
Adapting it
Add a calculated property that joins ServerAddresses with a comma so the values survive an export, and pass -CimSession to run the same query across a list of hosts.
If the result is unexpected
DNS client configuration is associated with the wrong adapter.
Machines may have virtual interfaces, multiple address families and changing interface names.
- Compare InterfaceIndex, address family and adapter status for the affected connection.
Validate the result
The exported DNS settings belong to the intended interface and address family.
Keep the check reliable
Retain interface identifiers alongside friendly names in configuration reports.