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
Last Updated on October 16, 2015