1

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 解决此问题的最佳方法是什么?

4

2 回答 2

2

我和一位同事一起工作,我们找到了解决方案:

bcdedit /set TESTSIGNING ON    
Import-Certificate -FilePath C:\webpagetest\WPOFoundation.cer -CertStoreLocation Cert:\LocalMachine\TrustedPublisher
cd C:\webpagetest
.\mindinst.exe c:\webpagetest\agent\dummynet\64bit\netipfw.inf -i -s
Enable-NetAdapterBinding -Name private0 -DisplayName ipfw+dummynet
  1. 使用 bcdedit 设置TESTSIGNING ON
  2. 然后,您必须将驱动程序提供的证书导入证书存储,使其成为受信任的驱动程序。
  3. 然后,使用mindinst.exe实用程序,您可以将驱动程序安装为网络服务绑定。
  4. 然后,标准的Enable-NetAdapterBinding模块将用于启用该服务。
于 2014-08-18T21:20:19.297 回答
0

您提到您能够在 Windows 2012 R2 中实现此功能,对吗?您是否使用了与 WebPageTest 捆绑的版本?WPT 的哪个版本?

您的步骤在 2012 年 (R1) 对我们有用,但 R2 给我们的错误如下所示:

C:\webpagetest\dummynet\64bit> .\ipfw.cmd
C:\webpagetest\dummynet\64bit>set CYGWIN=nodosfilewarning
C:\webpagetest\dummynet\64bit>ipfw -q flush
  5 [main] ipfw 1896 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer.  Please report this problem to the public mailing list cygwin@cygwin.com
C:\webpagetest\dummynet\64bit>ipfw -q pipe flush
  4 [main] ipfw 2944 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer.  Please report this problem to the public mailing list cygwin@cygwin.com

你有这个问题吗?在其他地方读到这是由旧版本的 Cygwin 引起的,我重新编译了 dummynet+ipfw 并安装了最新版本的 Cygwin,并将其 cygwin1.dll 放在输出目录中。当我将此服务安装到我的网络适配器堆栈中时,我会收到不同的错误:

C:\webpagetest\dummynet> .\ipfw.cmd
C:\webpagetest\dummynet>set CYGWIN=nodosfilewarning
C:\webpagetest\dummynet>ipfw -q flush
my_socket failed 2, cannot talk to kernel module
ipfw: socket: No error
C:\webpagetest\dummynet>ipfw -q pipe flush
my_socket failed 2, cannot talk to kernel module
ipfw: socket: No error

此外,它会杀死我的 DNS:

C:\> Resolve-DnsName google.com
Resolve-DnsName : google.com : No DNS servers configured for local system
于 2015-10-09T22:59:35.960 回答