Performance 获取具有MAC地址的以太网卡的网络使用情况

Performance 获取具有MAC地址的以太网卡的网络使用情况,performance,powershell,wmi,Performance,Powershell,Wmi,我正在尝试获取PowerShell脚本,以提供网卡名称、mac和当前使用情况。下面是我的半工作概念。我只是不知道如何与另一面的用法相匹配 $NetworkCards = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() Foreach ($Card in $NetworkCards) { if ($Card.NetworkInterfaceType -eq "Ethernet") {

我正在尝试获取PowerShell脚本,以提供网卡名称、mac和当前使用情况。下面是我的半工作概念。我只是不知道如何与另一面的用法相匹配

$NetworkCards = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() Foreach ($Card in $NetworkCards) { if ($Card.NetworkInterfaceType -eq "Ethernet") { $Statistics = $null Write-Host "Name: " $Card.Name Write-Host "Mac: " $Card.GetPhysicalAddress() $Statistics = $Card.GetIPv4Statistics() $Statistics #$BytesTotalPersec = $Statistics.BytesTotalPersec #$CurrentBandwidth = $Statistics.CurrentBandwidth #$Math = (($BytesTotalPersec*8)/$CurrentBandwidth)*100 #$Math = [Math]::Round($Math,2) #Write-Host $Math } } $NetworkCards=[System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() Foreach($NetworkCards中的卡){ if($Card.NetworkInterfaceType-eq“以太网”){ $Statistics=$null 写入主机名:$Card.Name 写入主机“Mac:$Card.GetPhysicalAddress() $Statistics=$Card.GetIPv4Statistics() $Statistics #$BytesTotalPersec=$Statistics.BytesTotalPersec #$CurrentBandwidth=$Statistics.CurrentBandwidth #$Math=($BytesTotalPersec*8)/$CurrentBandwidth)*100 #$Math=[Math]::四舍五入($Math,2) #编写主机$Math } }
我知道GetIPvStatistics是错的。在一个完美的世界里,我希望从Win32获取数据\u performatteddata\u Tcpip\u NetworkInterface

为什么不使用WMI类

PS> $data = Get-WmiObject Win32_PerfFormatteData_Tcpip_NetworkInterface | 
                Where {$_.Name -match 'Ethernet'}
PS> $data.BytesTotalPersec
28388

与另一边的用法相匹配?这是哪一面?我最初使用的正是wmi类。但问题是我找不到一种方法来确定显示的是哪张卡。我有一个4 nic服务器,它会对所有4个都显示“Intel Pro Model#”。没有mac、ID或实际名称。我需要一种方法,通过测试TotalPerSec来识别我正在获得哪张卡。