Xel*_*orz 8 networking powershell windows-10
我正在尝试找到一种方法来在 Windows 10 IOT 设备上配置永久静态 IP,并拔掉 Nic。我有一个脚本需要在设备到位之前在设备上运行,其中一部分是配置 NIC。当我使用以下内容时:
New-NetIpAddress -InterfaceIndex 10 -IpAddress 192.168.9.10 -PrefixLength 24 -DefaultGateway 192.168.9.1 -AddressFamily IPv4
我收到一个错误
New-NetIpAddress : Inconsistent parameters PolicyStore PersistentStore and Dhcp Enabled
我试图Set-NetIPInterface -InterfaceIndex 10 -Dhcp Disabled
在使用 New-NetIpAddress 命令之前显式关闭 DHCP,但我收到了同样的错误。
有什么建议?
您需要删除已分配给适配器的现有 DHCP IP 地址。您还应该为接口设置 DNS 服务器。我在下面提供了一个示例,但将 xxx.xxx.xxx.xxx 替换为您的 DNS 服务器 IP 地址。
您需要在 PersistentStore 的此接口的注册表中禁用 DHCP,然后才能设置 IP 地址。
Set-ItemProperty -Path “HKLM:\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces\$((Get-NetAdapter -InterfaceIndex 10).InterfaceGuid)” -Name EnableDHCP -Value 0
Remove-NetIpAddress -InterfaceIndex 10 -AddressFamily IPv4
Remove-NetRoute -InterfaceIndex 10 -AddressFamily IPv4 -Confirm:$false
New-NetIpAddress -InterfaceIndex 10 -IpAddress 192.168.9.10 -PrefixLength 24 -DefaultGateway 192.168.9.1 -AddressFamily IPv4
Set-DnsClientServerAddress -InterfaceIndex 10 -ServerAddresses "xxx.xxx.xxx.xxx"
Run Code Online (Sandbox Code Playgroud)
这个网站有一个很好的例子和过程的解释:https : //www.pdq.com/blog/using-powershell-to-set-static-and-dhcp-ip-addresses-part-1/
该网站讨论了您遇到的相同问题及其解决方案:http : //www.darrylvanderpeijl.com/inconsistent-parameters-policystore-persistentstore-and-dhcp-enabled/
归档时间: |
|
查看次数: |
4210 次 |
最近记录: |