Windows 10: command to remove DNS entries in Advanced Settings? Solved


  1. Posts : 3
    Win Server 2016
       13 Mar 2018 #1

    command to remove DNS entries in Advanced Settings?


    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
      My ComputerSystem Spec


  2. Posts : 35,332
    Triple boot - Win 10 Pro, Win 10 Pro Insider (2) - (and a sprinkling of VMs)
       13 Mar 2018 #2

    rman91 said: View Post
    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
    Just a S.W.A.G really, but if you combine deletion and addition in the same .bat, it may work. Delete them all, then add in the order you want, one line each.



    netsh dnsclient delete dnsserver "Local Area Connection" all

    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
      My ComputersSystem Spec

  3.    13 Mar 2018 #3

    I agree with F14Tomcat, because the only way to control ordering is to provide the entries in the order you want. By removing all previous entries, you "make room" to add replacements in the desired order. If, for some odd reason or another, that doesn't work, you may want to look into using an automation tool like AutoHotkey instead to capture the sequence of GUI commands for removing and adding those entries instead. For what I hope are obvious reasons, the batch file is the preferred alternative.
    HTH,
    --Ed--
      My ComputersSystem Spec


  4. Posts : 3
    Win Server 2016
    Thread Starter
       13 Mar 2018 #4

    thanks very much for the replies - will give this ago and let you know!

    cheers
      My ComputerSystem Spec


  5. Posts : 3
    Win Server 2016
    Thread Starter
       13 Mar 2018 #5

    @f14tomcat @EdTittel

    FYI - with a little more looking around i've managed to find something that works. Thanks for your help!

    netsh dnsclient delete dnsserver "Local Area Connection" allnetsh interface ip set dns name="Local Area Connection" static 10.91.201.56netsh interface ip add dns name="Local Area Connection" 10.91.201.57 index=2netsh interface ip add dns name="Local Area Connection" 10.91.201.55 index=3netsh interface ip add dns name="Local Area Connection" 10.91.201.54 index=4
      My ComputerSystem Spec

  6.    13 Mar 2018 #6

    Good work. The text got all jammed together, but with my "parsing hat" on I think I see what you did. Good work. Now, you can try it as a script on one or two test machines. If that works, then it works, too.
    Persistence pays off once again!
    --Ed--
      My ComputersSystem Spec


  7. Posts : 35,332
    Triple boot - Win 10 Pro, Win 10 Pro Insider (2) - (and a sprinkling of VMs)
       13 Mar 2018 #7

    rman91 said: View Post
    @f14tomcat @EdTittel

    FYI - with a little more looking around i've managed to find something that works. Thanks for your help!

    netsh dnsclient delete dnsserver "Local Area Connection" allnetsh interface ip set dns name="Local Area Connection" static 10.91.201.56netsh interface ip add dns name="Local Area Connection" 10.91.201.57 index=2netsh interface ip add dns name="Local Area Connection" 10.91.201.55 index=3netsh interface ip add dns name="Local Area Connection" 10.91.201.54 index=4
    Very slick! Good job! Glad to see you got it!!
      My ComputersSystem Spec


 

Related Threads
What is the easiest way to remove unwanted entries from the list that appears after right clicking a file and choosing Open With please? I have added successive versions of a program but don't see a simple 'Remove' option. Terry, East Grinstead,...
Hi,I need to determine which area to look at. I.e. exactly how does Windows configure itself to restart to the chosen advanced recovery option? I'd be happy to compare the results of running any command with that of a correctly functioning...
Hi, this is my first post and I hope this is the right forum section. I'm trying to make Windows 10 more "personal", adding/removing some features according to my needs. Now I'm customising the right click context menu and I'd like to remove...
I have the following entries in my system start up: Windows 10 Windows 10 Windows 7 How do I remove the last two entries so startup just shows one Windows 10 only or just boots right into Windows 10 without a start screen ? ...
I use my Favorites Bar in IE11 to hold a boatload full of links. I think it is easier to click on the >> and go to a new link than clicking on the Star to go to a new link. I decided to use the Favorites bar in EDGE but I forgot that you cannot...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 22:10.
Find Us