Submitted By: Jamalh Lagrone

Changes the primary and secondary DNS servers on a set of computers.

Visual Basic
Edit|Remove
On Error Resume Next

'List computers in the array that need their static DNS server settings changed
arrComputers = Array("computer1","Computer2")

For Each strComputer In arrComputers

'Set WMI Variables and query the WMI database
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

'change arrDNSServers to reflect the values of the new DNS Servers
For Each objNetCard in colNetCards
arrDNSServers = Array("1.2.3.4","1.2.3.5")
objNetCard.SetDNSServerSearchOrder(arrDNSServers)


'A message box will appear after each server is done. If you are doing many servers, please use this with cscript.

Next

msgbox "DONE!!!"

Next