Created
October 25, 2018 03:59
-
-
Save NeraSnow/e13c6eb91cd1fb0945eb8f7a5c7f6b7d to your computer and use it in GitHub Desktop.
Change DNS settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Credit: https://stackoverflow.com/questions/7690994/powershell-running-a-command-as-administrator | |
#> | |
# Runs as admin | |
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) | |
{ | |
$arguments = "& '" + $myinvocation.mycommand.definition + "'" | |
Start-Process powershell -Verb runAs -ArgumentList $arguments | |
Break | |
} | |
$dns1 = "218.85.157.99" #China Telecom DNS in Fuzhou, Fujian | |
$dns2 = "218.85.152.99" #China Telecom DNS in Xiamen, Fujian | |
netsh interface ip delete dnsservers name="以太网 3" all | |
netsh interface ip add dnsservers name="以太网 3" address=$dns1 | |
netsh interface ip add dnsservers name="以太网 3" address=$dns2 | |
Set-DnsClientGlobalSetting -SuffixSearchList @() | |
Read-Host "Press any key to exit..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment