如何使用power shell获取Get-WMIObject -Class Win32_PerfFormattedData的值

时间:2012-07-10 07:53:49

标签: powershell

$wmi = Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName $computer -Namespace $namespace. 

使用此power shell脚本如何获取参数的值?即我怎样才能得到这些的价值:

  • BytesReceivedPerSec
  • BytesSentPerSec
  • BytesTotalPerSec

2 个答案:

答案 0 :(得分:0)

Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName $computer -Namespace $namespace 
| Select BytesReceivedPerSec, BytesSentPerSec, BytesTotalPerSec

答案 1 :(得分:0)

这还不够吗?

$wmi = Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName $computer | select Name, BytesReceivedPerSec, BytesSentPerSec, BytesTotalPerSec

您还可以使用.NET进行统计总计:

$wmi = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() | foreach {$_.name; $_.GetIPv4Statistics()}