简体   繁体   English

如何通过Powershell更改禁用的网络适配器配置

[英]how to change a disabled network adapter configuration by powershell

I want to changed an networking adapter ip address. 我想更改网络适配器的IP地址。 For some security reason, we should change it when it is disabled. 出于安全原因,我们应该在禁用它时对其进行更改。

I used the following: 我使用了以下内容:

Set-NetIPAddress  -InterfaceAlias "Ethernet 3" -PrefixLength 20 -IPAddress 10.91.62.201 

But that failed with following message: 但这失败并显示以下消息:

Set-NetIPAddress : No matching MSFT_NetIPAddress objects found by CIM query for instances of the ROOT/StandardCimv2/MSFT_NetIPAddress class on the  CIM 
server: SELECT * FROM MSFT_NetIPAddress  WHERE ((IPAddress LIKE '10.91.62.201')) AND ((InterfaceAlias LIKE 'Ethernet 3'))

Is there anyone who know how to changed a disabed networking adapter configuration. 有谁知道如何更改无效的网络适配器配置。 Thanks. 谢谢。

You can update it through the registry: 您可以通过注册表进行更新:

Get the adapter object (We need the GUID as the registry identifies the adapters by guid): 获取适配器对象(我们需要GUID,因为注册表通过guid标识适配器):

$adapter = Get-WmiObject Win32_NetworkAdapter | WHERE {$_.DeviceID -eq "1"}

Update the registry accordingly: 相应地更新注册表:

New-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\$($adapter.guid)" -Name IPAddress -Value "10.91.62.201" -Force

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM