Changing the DNS server value on a list of computers using Windows Powershell
First, populate c:\comp.txt (or any other text file) with a list of target devices (one per line).
Then modify the $newDNS variable so that its correct to your environment.
$servers = get-content C:\comp.txt foreach($server in $servers) { Write-Host "Connect to $server..." $nics = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $server -ErrorAction Inquire | Where{$_.IPEnabled -eq "TRUE"} $newDNS = "10.124.0.1","10.124.0.2" foreach($nic in $nics) { Write-Host "`tExisting DNS Servers " $nic.DNSServerSearchOrder $x = $nic.SetDNSServerSearchOrder($newDNS) if($x.ReturnValue -eq 0) { Write-Host "`tSuccessfully Changed DNS Servers on " $server } else { Write-Host "`tFailed to Change DNS Servers on " $server } } }