#!powershell$adapter = Get-netadapter |? {$_. Interfacedescription-ne "Microsoft km-test Loopback Adapter"}if ($adapter-ne $null) {$adapter | Rename-netadapter-newname "ETH" Disable-netadapterbinding-name "eth"-componentid ms_tcpip6 netsh interface ipv4 Set DNS Name= "ETH" source=static address=114.114.114.114 primary netsh interface ipv4 add dnsserver name= "ETH" addres s=8.8.8.8 index=2 netsh interface ipv4 add dnsserver name= "Eth" address=202.96.209.133 index=3}
These are the scripts for PowerShell to set the DNS address for PowerShell 4 and later
WINDWOS 2008 Changing the DNS method:
$WMI =get-wmiobject-class win32_networkadapterconfiguration-filter ipenabled=true-computername computer name $WMI. SetDNSServerSearchOrder (' 8.8.8.8 ')
This article is from the "Zengestudy" blog, make sure to keep this source http://zengestudy.blog.51cto.com/1702365/1928929
PowerShell Script Settings DNS