нужна командная строка для проверки дуплексного статуса на платах NIC Windows

3168
Jacko

это будет для Windows 7

Я попробовал следующую команду powershell

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

но я не могу получить полезную информацию от этого.

2
Смотрите этот [связанный вопрос] (http://superuser.com/q/86581/820). Не похоже, что это то, что доступно через Windows API. Обычно это доступно только на уровне драйвера NIC. Возможно, у вашего производителя NIC есть что-то доступное. [Этот пост] (http://opennms.530661.n2.nabble.com/Can-WMI-get-duplex-settings-td2451090.html) также подтверждает это. heavyd 10 лет назад 1

1 ответ на вопрос

0
xXhRQ8sD2L7Z

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\\" 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