2

this woud be for windows 7

I tried the following powershell command

get-wmiobject Win32_NetworkAdapter | foreach-object {   get-wmiobject -namespace root/WMI -class MSNdis_macOptions -filter "InstanceName='$($_.Name)'"}

but I can't seem to get usable info from this.

1
  • 1
    See this related question. It doesn't look like this is something that is available via the Windows API. It is typically something only available at the NIC driver level. Perhaps your NIC manufacturer might have something available. This post also confirms that.
    – heavyd
    May 9, 2014 at 21:14

1 Answer 1

0

Since I don't have Windows 8 (and Get-NetAdapterAdvancedProperty) I used this to get the Speed/Duplex:

Update: This was driving me crazy. I was getting various errors with keys not existing, and it turns out certain devices will not have a speed/duplex like USB passthrough and Microsoft Cluster device. I updated it to use the enum value of duplex and also cycle through all available NICs.

Also, the original wasn't looking at the registry on the target, rather the localhost.

Function Get-NICSpeedDuplex {
   Param (
      [String]$computer
   )
   $key = "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"

   gwmi -Class Win32_NetworkAdapterConfiguration -Computer $computer -Filter "IPEnabled='$true'" | % {
      $suffix = $([String]$_.Index).PadLeft(4,"0")

      #get remote registry value of speed/duplex
      $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer)
      $service = $reg.OpenSubKey("$key\\$suffix\\Ndi").GetValue("Service")
      If ($service -imatch "usb") {
         # This USB device will not have a '*SpeedDuplex' key
         New-Object PSObject -Property @{
            "Device" = $_.Description
            "Speed/Duplex" = "USB Device"
         }
      } ElseIf ($service -imatch "netft") {
         # Microsoft Clustered Network will not have a '*SpeedDuplex' key
         New-Object PSObject -Property @{
            "Device" = $_.Description
            "Speed/Duplex" = "Cluster Device"
         }
      } Else {
         $speedduplex = $reg.OpenSubKey("$key\\$suffix").GetValue("*SpeedDuplex")
         $enums = "$key\$suffix\Ndi\Params\*SpeedDuplex\enum"
         New-Object PSObject -Property @{
            "Device" = $_.Description
            "Speed/Duplex" = $reg.OpenSubKey($enums).GetValue($speedduplex)
         }
      }
   }
}

It's a little clunky hardcoding that registry key, but it seems to work on my Windows 7 PC and remote servers (2003/2008/2012). From this article : "The subkey represents the class of network adapter devices that the system supports."

Output of the script:

PS C:\> Get-NICSpeedDuplex "test-server-xx" | ft -auto

Speed/Duplex     Device                                    
------------     ------                                    
Auto Negotiation vmxnet3 Ethernet Adapter                  
Auto Negotiation vmxnet3 Ethernet Adapter #4               
Cluster Device   Microsoft Failover Cluster Virtual Adapter

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .