windows 通过域策略开机脚本批量改服务器dns

最近公司ad域迁移,客户端dns要批量修改,现归纳以下2个脚本:

 

1.bat

 

@echo off
netsh interface ip add address "本地连接" gateway=192.168.1.1 gwmetric=0
netsh interface ip delete dns "本地连接" all
netsh interface ip add dns "本地连接" addr=192.168.1.13 index=1
netsh interface ip add dns "本地连接" addr=192.168.1.12 index=2
ipconfig /flushdns
:exit

 

1.vbs

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrDNSServers = Array("192.168.1.13", "192.168.1.12")
    objNetCard.SetDNSServerSearchOrder(arrDNSServers)
Next

你可能感兴趣的:(windows,服务器,客户端,gateway,interface)