PowerShell脚本,以获得Windows计算机的网卡速度

Mar*_*rth 7 windows powershell wmi

什么是PowerShell脚本以获得特定Windows机器的网卡运行速度?

我知道这可以通过基于WMI查询的语句来完成,并且一旦我完成它就会发布一个答案.

Mar*_*rth 9

基本命令是

Get-WmiObject -ComputerName 'servername' -Class Win32_NetworkAdapter | `
    Where-Object { $_.Speed -ne $null -and $_.MACAddress -ne $null } | `
    Format-Table -Property SystemName,Name,NetConnectionID,Speed
Run Code Online (Sandbox Code Playgroud)

请注意,ComputerName参数采用数组,因此您可以针对多台计算机运行此操作,前提是您拥有权限.用*****替换Format-Table属性列表以获得更全面的可用属性列表.您可能希望过滤这些属性以删除您不感兴趣的条目.

使用内置字节乘数后缀(MB,GB等)也可以根据您的需要使速度更具可读性.您可以将此指定为Format-Table -Property数组上的HashTable条目,例如

Format-Table -Property NetConnectionID,@{Label='Speed(GB)'; Expression = {$_.Speed/1GB}}
Run Code Online (Sandbox Code Playgroud)