How to change DNS and WINS servers values on multiple Windows Machines?

Just think if your DNS and WINS server got changed and you as a Systems Administrator needs to upgrade the same on multiple windows servers/machines. Below Powershell script can help you do in a very less time.

 

NOTE : Before you do please test the same script in test machine first, you can add single machine name where you are giving path of computer names file.

function Set-DNSWINS {
#Get NICS via WMI
$NICs = Get-WmiObject ‘
-Class Win32_NetworkAdapterConfiguration ‘
–ComputerName $_ ‘
-Filter “IPEnabled=TRUE”

foreach($NIC in $NICs) {
$DNSServers = “12.34.5.67”,”76.54.3.21″
$NIC.SetDNSServerSearchOrder($DNSServers)
$NIC.SetDynamicDNSRegistration(“TRUE”)
$NIC.SetWINSServer(“12.345.67.890”, “12.345.67.891”)
}
}

function Get-FileName {
$computer = Read-Host “Path or text File with ComputerNames”
return $computer
}

 

$f = Get-FileName
Get-Content $f | foreach {Set-DNSWINS}

 

 

You may also like...

Leave a Reply

%d bloggers like this: