1

tl;dr trying to automate a driver / adapter binding / adapter service using PowerShell / (Set|Get)-NetAdapterBinding / PnPUtil / nvspbind

I've been exploring automating the installation of the dummynet driver on a network adapter on Windows Server 2012 and 2012 R2.

I need to automate these steps:

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)

I believe I can add the driver's INF files to the Driver Store using the PnPUtil utility.

I've explored the (Set|Get)-NetAdapterBinding powershell modules, and I can't seem to get the driver to register properly.

Here is the result of a Get-NetAdapterBinding after I installed it via the manual method:

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;}

Here is my attempt to Set-NetAdapterBinding with the arguments documented for that module:

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

In trying to figure out the best way to do this, I also came across the nvspbind utility, and attempted to use this tool to add the driver. Unfortunately, I can't seem to get that to bind to the adapter either. The utility just keeps spitting out it's usage information.

What's the best way to approach this issue using PowerShell?

Linuturk
  • 31
  • 4
  • can it be installed from the command prompt? – Jimbo Aug 15 '14 at 18:33
  • Not using any tool that I know about. The closest I've come is the PnPUtil and nvspbind tools, but I can't get it to add the binding after the INF files are registered in the Driver Store. – Linuturk Aug 15 '14 at 18:40

2 Answers2

2

I worked with a co-worker and we found a solution:

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. Use bcdedit to set TESTSIGNING ON
  2. Then, you have to import the Certificate provided by the driver into the Certificate Store so it is a trusted driver.
  3. Then, using the mindinst.exe utility, you can install the driver as a Network Service Binding.
  4. Then, the standard Enable-NetAdapterBinding module will work to enable the service.
Linuturk
  • 31
  • 4
  • I failed to achieve this task in windows-7. Probably NetAdapterBinding module doesn't supported by it, it may required windows-8 or better. Which OS you used? I able to execute **mindinst.exe** and could see **ipfw+dummynet** check box under LAN properties UI. When I tried **"ipfw list" in cmd, got this error "my_socket failed 2, cannot talk to kernel modules ipfw: socket: No such file or directory"**. Could you please help me how can i complete this task in windows-7? Thank in adv. – Kulamani Oct 18 '16 at 12:46
0

You mentioned that you were able to get this working in Windows 2012 R2, correct? Did you use the version bundled with WebPageTest? Which verison of WPT?

Your steps worked for us in 2012 (R1), but R2 gives us errors that look like this:

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

Did you have this problem? Reading elsewhere that this was caused by an old version of Cygwin, I recompiled dummynet+ipfw with the latest version of Cygwin installed, and dropped its cygwin1.dll in the output dir. When I install this service into my network adapter stack, I get different errors:

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

Also, it kills my DNS:

C:\> Resolve-DnsName google.com
Resolve-DnsName : google.com : No DNS servers configured for local system
Adam Cath
  • 317
  • 3
  • 4
  • I have seen issues like you are reporting and I don't think we ever came up with a solution. We are just making due without the traffic shaping at this time. – Linuturk Oct 11 '15 at 14:13
  • @Adam, Did you solved this problem any how? I am have exactly same error when trying to install ipfw in windows-10. Could you help me for this? – Kulamani Oct 04 '16 at 05:47