#!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方法:
$wmi=get-wmiobject -class win32_networkadapterconfiguration -filter ipenabled=true -computername 计算机名 $wmi.SetDNSServerSearchOrder(‘8.8.8.8‘)
时间: 2024-11-08 09:55:52