tl;博士尝试使用 PowerShell / (Set|Get)-NetAdapterBinding / PnPUtil / nvspbind 自动化驱动程序/适配器绑定/适配器服务
我一直在探索在 Windows Server 2012 和 2012 R2 的网络适配器上自动安装dummynet驱动程序。
我需要自动化这些步骤:
Pull up the properties for the Network Adapter that is used to access the Internet
Click "Install"
Select "Service" and click "Add"
Click "Have Disk" and navigate to webpagetest\dummynet
Select the ipfw+dummynet service (and click through any warnings about the driver being unsigned)
我相信我可以使用PnPUtil实用程序将驱动程序的 INF 文件添加到驱动程序存储中。
我探索了 (Set|Get)-NetAdapterBinding powershell 模块,但似乎无法让驱动程序正确注册。
这是我通过手动方法安装 Get-NetAdapterBinding 后的结果:
PS C:\Users\Administrator> Get-NetAdapterBinding public0 -DisplayName ipfw+dummynet | format-list
Caption : MSFT_NetAdapterBindingSettingData 'Citrix PV Network Adapter #0'
Description : ipfw+dummynet
ElementName : unipi_ipfw
InstanceID : {906E5591-5C6C-4D07-BB8D-BA387BA4B646}::unipi_ipfw
InterfaceDescription : Citrix PV Network Adapter #0
Name : public0
Source : 1
SystemName : ComputerName
BindName : Ipfw
Characteristics : 17424
ComponentClassGuid : {4D36E974-E325-11CE-BFC1-08002BE10318}
ComponentClassName : Filter
ComponentID : unipi_ipfw
DisplayName : ipfw+dummynet
Enabled : True
PSComputerName :
ifAlias : public0
InterfaceAlias : public0
ifDesc : Citrix PV Network Adapter #0
Get-NetAdapterBinding -Name public -DisplayName ipfw+dummynet | GM
TypeName: Microsoft.Management.Infrastructure.CimInstance#ROOT/StandardCimv2
/MSFT_NetAdapterBindingSettingData
Name MemberType Definition
---- ---------- ----------
ifAlias AliasProperty ifAlias = Name
ifDesc AliasProperty ifDesc = InterfaceDescription
InterfaceAlias AliasProperty InterfaceAlias = Name
Clone Method System.Object ICloneable.Clone()
Dispose Method void Dispose(), void IDisposable.Dis...
Equals Method bool Equals(System.Object obj)
GetCimSessionComputerName Method string GetCimSessionComputerName()
GetCimSessionInstanceId Method guid GetCimSessionInstanceId()
GetHashCode Method int GetHashCode()
GetObjectData Method void GetObjectData(System.Runtime.Se...
GetType Method type GetType()
ToString Method string ToString()
BindName Property string BindName {get;}
Caption Property string Caption {get;set;}
Characteristics Property uint32 Characteristics {get;}
ComponentClassGuid Property string ComponentClassGuid {get;}
ComponentClassName Property string ComponentClassName {get;}
ComponentID Property string ComponentID {get;}
Description Property string Description {get;set;}
DisplayName Property string DisplayName {get;}
ElementName Property string ElementName {get;set;}
Enabled Property bool Enabled {get;set;}
InstanceID Property string InstanceID {get;set;}
InterfaceDescription Property string InterfaceDescription {get;}
Name Property string Name {get;}
PSComputerName Property string PSComputerName {get;}
Source Property uint32 Source {get;}
SystemName Property string SystemName {get;}
这是我尝试使用为该模块记录的参数设置 NetAdapterBinding:
Set-NetAdapterBinding -Name public0 -Component unipi_ipfw -Enabled $True
Set-NetAdapterBinding : No matching MSFT_NetAdapterBindingSettingData objects
found by CIM query for instances of the
ROOT/StandardCimv2/MSFT_NetAdapterBindingSettingData class on the CIM server:
SELECT * FROM MSFT_NetAdapterBindingSettingData WHERE ((Name LIKE 'public0'))
AND ((ComponentID LIKE 'unipi[_]ipfw')). Verify query parameters and retry.
At line:1 char:1
+ Set-NetAdapterBinding -Name public0 -Component unipi_ipfw -Enabled $True
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (MSFT_NetAdapterBindingSettingDa
ta:String) [Set-NetAdapterBinding], CimJobException
+ FullyQualifiedErrorId : CmdletizationQuery_NotFound,Set-NetAdapterBindin
g
在尝试找出最好的方法时,我还遇到了nvspbind实用程序,并尝试使用此工具添加驱动程序。不幸的是,我似乎也无法将其绑定到适配器。该实用程序只是不断吐出它的使用信息。
使用 PowerShell 解决此问题的最佳方法是什么?