1
2
3
4
5
6
7
8
9
10
|
#!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"
address=8.8.8.8 index=2
netsh interface ipv4 add dnsserver name=
"Eth"
address=202.96.209.133 index=3
}
|
以上就是powershell设置dns地址的脚本,适用于powershell 4及以上版本
windwos 2008 更改DNS方法:
1
2
|
$wmi
=
get-wmiobject
-class win32_networkadapterconfiguration -
filter
ipenabled=true -computername 计算机名
$wmi
.SetDNSServerSearchOrder(
'8.8.8.8'
)
|
本文转自 曾哥最爱 51CTO博客,原文链接:http://blog.51cto.com/zengestudy/1928929,如需转载请自行联系原作者