$computer = get-content "C:\dns\dns.txt" $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq “TRUE”} | select PScomputerName,DNSServersearchOrder | where DNS=1.1.1.1 Foreach($NIC in $NICs) { $DNSServers = “2.2.2.2",”3.3.3.3" $NIC.SetDNSServerSearchOrder($DNSServers) $NIC.SetDynamicDNSRegistration(“TRUE”) }
I have the need to change the DNS settings on several servers. I am trying to do this using PowerShell and a txt file. Problem being I need to make sure I am only changing the DNS settings on the NICS that currently have a certain IP. I am not able to make this work. Any suggestions on how I could do this? Please see code above
Thanks for your help