Windows 10 command to remove DNS entries in Advanced Settings?

rman91

New Member
Joined
Mar 13, 2018
Hi All

Wondering if anyone knows a command to remove the DNS entries within the advanced TCP/IP settings?

The primary and secondary DNS IP need to be changed with the tertiary and quaternary DNS IP. Simple enough doing it manually but there's over 50 VMs this needs to be done on so i'm trying to write a script for this.

i did try to the below command but as the IPs are already added it wouldn't re-arrange them into the given order

e.g. (IPs have been randomised)

netsh dnsclient add dnsserver "Local Area Connection" 10.91.201.56 1

netsh dnsclient add dnsserver "Local Area Connection" 10.91.201.57 2

netsh dnsclient add dnsserver "Local Area Connection" 10.91.207.55 3

netsh dnsclient add dnsserver "Local Area Connection" 10.91.207.54 4

Any help is greatly appreciated - thanks
 
netsh isn't very robust. You won't be able to reorder them. What you will want to do is remove all the entries and re-add them.

netsh interface ipv4 delete dnsservers "Local Area Connection" 10.91.201.56
..57
..55
..54

then re-add in the order you want
netsh interface ipv4 add dnsservers "Local Area Connection" <address> index=#
 
Back
Top Bottom