I have a variety of situations where my dns settings need to be different. Its been a pain to manually change them every time so i decided to create a powershell script to automate this:
$wmi = (Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled ='true' and DHCPEnabled='true'" | ? {$_.Description -eq "Intel Nic Adapter #2"}) $dnsServers = @("208.67.222.222", "208.67.220.220") $wmi.SetDNSServerSearchOrder($dnsServers)
The script executes without any errors but when i go check the specific adapter i’m targeting its settings haven’t changed from their default of obtaining the dns automatically. I don’t need to change any other setting except for the DNS Server addresses. I’ve checked the $wmi object above and i verified it is the adapter i want to be changed. I also tried to pass in a static string to SetDNSServerSearchOrder ($wmi.SetDNSServerSearchOrder(“208.67.220.220”)) but that didn’t work either. I’m not running the script as administrator and i’m assuming thats ok since i didn’t receive any errors when running the script. This probably doesn’t matter but this script is running on Windows 10 Fall Creators Update. Any help would be appreciated.