Powershell 脚本 修改IP与DNS

PS1 脚本修改 IP 与 DNS

新建一个文本文件(txt),然后把下面的内容贴上去,再改扩展名为(txt)(ps1)

一次性修改 IP、子网掩码、网关、DNS 自己喜欢就好!

image.png

具体脚本:

$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'"

$wmi.EnableStatic("192.192.192.1", "255.255.255.0")

$wmi.SetGateways("192.192.192.1", 1)

Get-DnsClientServerAddress -AddressFamily IPv4 |

Out-GridView -PassThru |

foreach {

 Set-DnsClientServerAddress -InterfaceIndex $_.InterfaceIndex -Addresses '192.192.192.1','192.192.192.2'

}

ipconfig /flushdns

-------- 脚本完 --------

然后右键……选择……确认……

image.png

---------------- 完 ----------------



猜你喜欢

转载自blog.51cto.com/happynews/2304854