The PowerShell script lists the DNS servers configured on the active network interfaces of a Windows system. It filters the network interfaces to include only those that are currently connected (status "Up") and retrieves the DNS server information for those interfaces. The output is sorted by interface metric, which reflects the priority of the interfaces, and includes the interface alias, interface metric, and DNS server IP addresses.
- Save the script as
List-Prioritized-DNS-Servers.ps1
. - Navigate to the directory where the script is saved.
- Run the script using the command:
.\List-Prioritized-DNS-Servers.ps1
.
The script outputs a table with the following columns:
InterfaceAlias
: The name of the network interface.InterfaceMetric
: The metric of the network interface, reflecting its priority. Lower number have highest priority.DnsServers
: The IP addresses of the DNS servers associated with the interface.
InterfaceAlias InterfaceMetric DnsServers Ethernet 5 20 192.168.8.1 Ethernet 5 20 192.168.8.2 Wi-Fi_Laptop 45 10.0.0.1 Wi-Fi_Laptop 45 1.1.1.1 Wi-Fi_Laptop 45 8.8.8.8