2016-07-14 135 views
0

我需要在Windows 10未连接网络时设置网卡的IP地址。我已经试过:使用Powershell在断开的网卡上设置静态IP,有可能吗?

Set-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "192.168.5.10" -PrefixLength 24 

New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "192.168.5.10" -PrefixLength 24 

设置-NetIPAddress不返回任何错误,但它不设置地址。它确实切换IPV4属性中的选择以使用特定地址,但不填写值。

新NetIPAddress提供了以下错误:

New-NetIPAddress : Inconsistent parameters PolicyStore PersistentStore and  Dhcp Enabled 
At line:1 char:1 
+ New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "192.168.5.10" -Pr  ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+ CategoryInfo   : InvalidArgument: (MSFT_NetIPAddress:ROOT/StandardCimv2/MSFT_NetIPAddress) [New-NetIPAddress], CimException 
+ FullyQualifiedErrorId : Windows System Error 87,New-NetIPAddress 

我做了一些挖掘,发现这里:http://www.darrylvanderpeijl.nl/tag/policystore/该网卡需要配置IP地址之前的连接。

基本上我试图在数百台电脑上设置加载项NICS的IP地址。在计算机投入生产之前,这个特定的NIC将不会连接。我对Powershell仍然很陌生,甚至有可能配置断开的NIC的IP地址?

我愿意尝试其他技术,如果需要的话。

回答

1

没关系......

netsh interface ip set address "Ethernet" static 192.168.5.10 255.255.255.0 

正是这么做的,并且可以从名为.ps1脚本运行。

0

这是你如何找到断开连接的适配器

get-wmiobject win32_networkadapter -filter "netconnectionstatus = 7" | select netconnectionid, name, InterfaceIndex, netconnectionstatus