我找到了
Determining the network connection link speed
现在我试图将Win32_PerfRawData_Tcpip_NetworkInterface中的数据与
Win32_NetworkAdapter(或Win32_NetworkAdapterConfiguration).
现在我试图将Win32_PerfRawData_Tcpip_NetworkInterface中的数据与
Win32_NetworkAdapter(或Win32_NetworkAdapterConfiguration).
在类Win32_PerfRawData_Tcpip_NetworkInterface我没有看到任何
我可以用来引用的索引或唯一键
Win32_NetworkAdapterConfiguration或Win32_NetworkAdapter.
我尝试使用theNameinWin32_PerfRawData_Tcpip_NetworkInterface
和Win32_NetworkAdapter`,但它们看起来仍然不同.
例如
Name: Intel(R) PRO/1000 PL Network
Connection
VS
Name: Intel[R] PRO_1000 PL Network
Connection
任何提示?
先谢谢你,
Milde
===
也许那段代码会帮助你帮助我们:)
# I got the DeviceID of a NIC and use it to get the "NetConnection ID": $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\CIMV2") or die "Exit: WMI connection Failed. \n"; $colNicSetts = $objWMIService->ExecQuery( "SELECT * FROM Win32_NetworkAdapter Where DeviceID = '$ID'","WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly); foreach my $objItem (in $colNicSetts){ $NetConnID = $objItem->{NetConnectionID}; } # => $NetConnID stores "Intel(R) PRO/1000 PL Network Connection". # Now I tried to get the Link Speed with sth. like that: $collItems = $objWMIService->ExecQuery( "SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface Where Name = '$NetConnID'",wbemFlagReturnImmediately | wbemFlagForwardOnly); foreach my $objItem (in $collItems){ $LinkSpeed = $objItem->{CurrentBandwidth}; } # "Win32_PerfRawData_Tcpip_NetworkInterface" contains "Intel[R] PRO_1000 PL Network" Connection # "Intel(R) PRO/1000 PL Network Connection" != Intel[R] PRO_1000 PL Network Connection # => $LinkSpeed empty
好.感谢您发布短脚本.当你正在努力的时候,我正在使用
DBD::WMI跟踪一个不同的轨道并挖掘文档,看看你是否遗漏了任何东西.
原文链接:https://www.f2er.com/windows/372195.html#!/usr/bin/perl use strict; use warnings; use DBI; use Data::Dumper; my $computer = '.'; ($computer) = @ARGV if @ARGV; my $dbh = DBI->connect("dbi:WMI:$computer",undef,{ RaiseError => 1},); print "=== From Win32_NetworkAdapter ===\n"; my $name = $dbh->selectall_arrayref( 'SELECT * FROM Win32_NetworkAdapter WHERE DeviceID = 11' )->[0]->[0]->{Name}; (my $canonname = $name) =~ s/[^A-Za-z0-9]/_/g; print "Name: $name\nCanonical name: $canonname\n\n"; my $sth = $dbh->prepare( 'SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface' ); $sth->execute; print "=== From Win32_PerfRawData_Tcpip_NetworkInterface ===\n"; while (defined (my $adapter = $sth->fetchrow_arrayref )) { my $conf = $adapter->[0]; my $perfname = $conf->{Name}; (my $canonperfname = $perfname) =~ s/[^A-Za-z0-9]/_/g; if ( $canonperfname =~ /^$canonname/ ) { print "Name: $perfname\nCanonical name: $canonperfname\n"; print $conf->{CurrentBandwidth},"\n\n"; last; } }
输出:
=== From Win32_NetworkAdapter === Name: Intel(R) PRO/Wireless 3945ABG Network Connection Canonical name: Intel_R__PRO_Wireless_3945ABG_Network_Connection === From Win32_PerfRawData_Tcpip_NetworkInterface === Name: Intel[R] PRO_Wireless 3945ABG Network Connection - Packet Scheduler Miniport Canonical name: Intel_R__PRO_Wireless_3945ABG_Network_Connection___Packet_Scheduler_Miniport 54000000