This only works on Windows 8, 8.1, 10 as the Cmdlets Set-DnsClientServerAddress Get-DnsClientServerAddress are introduced in Windows 8.
First get the interface name(s) you want to modify
Get-DnsClientServerAddress
Change the code below to the interface you wish to change
$primarydns = $args[0] $secondarydns = $args[1] Set-DNSClientServerAddress –interfaceAlias Wi-Fi –ServerAddresses ($primarydns,$secondarydns) Get-DnsClientServerAddress -InterfaceAlias Wi-Fi
.\UpdateDNS.ps1 8.8.8.8 8.8.4.4
Originally Posted on September 24, 2015
Last Updated on October 16, 2015
Last Updated on October 16, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.