Powershell 如何使用power shell获取get WMIOObject类Win32_performattedData的值
使用这个powershell脚本如何获取参数的值?i、 e.我如何获得这些的价值:Powershell 如何使用power shell获取get WMIOObject类Win32_performattedData的值,powershell,Powershell,使用这个powershell脚本如何获取参数的值?i、 e.我如何获得这些的价值: BytesReceivedPerSec BytesSentPerSec BytesTotalPerSec 这还不够吗 Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName $computer -Namespace $namespace | Select BytesReceivedPerSec, Byt
BytesReceivedPerSec
BytesSentPerSec
BytesTotalPerSec
- 这还不够吗
Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName $computer -Namespace $namespace
| Select BytesReceivedPerSec, BytesSentPerSec, BytesTotalPerSec
您还可以使用.NET进行统计合计:
$wmi = Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName $computer | select Name, BytesReceivedPerSec, BytesSentPerSec, BytesTotalPerSec
谢谢你的回复。但是我将如何在不同的变量中获得这些参数的值并打印出来。请帮助我这样做。我只需要使用power shell,但我对这种脚本语言非常陌生。为什么需要更多的变量<代码>$wmi.BytesReceivedPerSec或
$wmi.BytesSentPerSec
等都可以执行此操作。如果您有多个NIC,则需要将索引数组指定为$wmi[0]。对于数组中的第一个NIC,BytesReceivedPerSec
。感谢您的回复。但是我将如何在不同的变量中获得这些参数的值并打印出来。请帮助我做到这一点。我只需要使用power shell,但我对这种脚本语言非常陌生。
$wmi = Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName $computer | select Name, BytesReceivedPerSec, BytesSentPerSec, BytesTotalPerSec
$wmi = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() | foreach {$_.name; $_.GetIPv4Statistics()}