Using Powershell to Set DNS on remote machines

$computer = Get-Content "c:\users\path\to\my.csv"
Foreach($computer in $computer){
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq “TRUE”}
}
  Foreach($NIC in $NICs) {
$DNSServers = “8.8.8.8",”192.168.40.119" # set dns servers here
 $NIC.SetDNSServerSearchOrder($DNSServers)
 $NIC.SetDynamicDNSRegistration(“TRUE”)
}
$computer = Get-Content "c:\users\path\to\my.csv"
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq “TRUE”}
  Foreach($NIC in $NICs) {
$DNSServers = “8.8.8.8",”192.168.40.119"
 $NIC.SetDNSServerSearchOrder($DNSServers)
 $NIC.SetDynamicDNSRegistration(“TRUE”)
}

Leave a Reply

Your email address will not be published. Required fields are marked *