Fady AbuZuaiter
asked on
Replace DNS Server by Batch File
Hello,
I'm changing the DNS Servers on our Environment to new IPs. i found a batch script which worked perfectly on the Servers that have one connection only but for the servers that have two it didn't worked as it some time change the DNS for the correct one and some time no.
how i can modify it to change the DNS for the network interface that have the old IPs or that Connected to the Domain.
below is the script & I want it as batch to deploy it by SCCM
I'm changing the DNS Servers on our Environment to new IPs. i found a batch script which worked perfectly on the Servers that have one connection only but for the servers that have two it didn't worked as it some time change the DNS for the correct one and some time no.
how i can modify it to change the DNS for the network interface that have the old IPs or that Connected to the Domain.
below is the script & I want it as batch to deploy it by SCCM
@echo off
set dnsserver=10.10.1.3
set dnsserver2=10.10.1.4
for /f "tokens=1,2,3*" %%i in ('netsh interface show interface') do (
if %%i EQU Enabled (
rem echo change "%%l" : %dnsserver%
netsh interface ipv4 set dnsserver name="%%l" static %dnsserver% both
netsh interface ipv4 add dnsserver name="%%l" %dnsserver2% index=2
Exit
)
)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad to help :)