PowerShell设置固定ip

Posted 小蚂蚁_CrkRes

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PowerShell设置固定ip相关的知识,希望对你有一定的参考价值。

PowerShell设置固定ip

$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'"
$wmi.EnableStatic("192.168.1.100", "255.255.255.0")  #设置IP地址及掩码
$wmi.SetGateways("192.168.1.1")   #设置默认网关
#New-NetIPAddress -InterfaceIndex 19 -IpAddress 192.168.1.2 -PrefixLength 24 -DefalutGateway 192.168.1.1
#Get-DnsClientServerAddress -AddressFamily IPv4 |Out-GridView -PassThru |
Set-DnsClientServerAddress -InterfaceIndex 19 -Addresses '8.8.8.8'
ipconfig /flushdns


powerShell设置IP为固定获取

Set-NetIPInterface -InterfaceIndex 19 -Dhcp Enabled
Set-DnsClientServerAddress -InterfaceIndex 19 -ResetServerAddresses

其中的 -InterfaceIndex 19 参数可用以下

Get-DnsClientServerAddress -AddressFamily IPv4 |Out-GridView -PassThru

 

以上是关于PowerShell设置固定ip的主要内容,如果未能解决你的问题,请参考以下文章