DNS settings Script

I am looking for a script to use with group policy to set the Primary, Secondary, and Advance DNS settings DNS entry for all my servers with Static IP addresses.  I am getting ready to change some IP addresses of my DNS servers and did not want to do it manually on all servers.  Does anyone know of a script that will accomplish this?
Serenea CarpenterAsked:
Who is Participating?
dkumar82Connect With a Mentor Commented:
You can perform using NETSH command. Below is few example

You can write a simple batch file
eg at \\pcname xx:xx netsh ... or Using Run as

This changes the IP address and Default Gateway:
netsh int ip set address "local area connection" static {} {} 1

This changes DNS:
netsh int ip set dns "local area connection" static {} primary
You will want to change the values between the curly braces, but do not use the curly braces when you run the command.
To change the interface back to DHCP (get IP automatically) use this command:
netsh int ip set address "local area connection" dhcp

netsh int ip set dns "local area connection" dhcp
Serenea CarpenterAuthor Commented:
That will work if i can make some changes to the DNS one.  I dont want to run this on every server individually.  That would defeat the purpose of having a script.  Can I use wildcards in the IP address?  Like 192.168.*.*?  Also I suppose for the secondary i would just add a second line to this that ends with secondary?  And I do have four entries i want to add so would would i end with for the two others i want to add in the DNS advance page?  Thanks for your help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.