command to remove DNS entries in Advanced Settings?

rman91

New Member
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
 


Neemobeer

Windows Forum Team
Staff member
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=#
 


This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.
Top