用 Get-Counter 采样性能计数器

把 CPU、磁盘、内存及自定义计数器读成对象。

Windows监控性能PowerShell低风险
运行 Get-Counter '\Processor(_Total)\% Processor Time' -SampleInterval 1 -MaxSamples 5。

01命令

命令
$ Get-Counter '\Processor(_Total)\% Processor Time' -SampleInterval 1 -MaxSamples 5

02作用说明

Get-Counter 把计数器数据返回为可过滤、比较或导出 CSV 的对象,并支持 -ComputerName 读取远程主机。这让阈值检查和趋势日志可脚本化,而非靠肉眼盯 PerfMon 图表。

03风险

风险低风险
使用条件Windows 10/11 with PowerShell 5.1 or PowerShell 7+
!注意: 计数器名称本地化,引号必须正确;可用 -ListSet 在目标系统上发现名称。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • Get-Counter
    Microsoft Learn · vendor-doc · 2026-09-20
    依据: Reads performance counter samples, including remote computers.

最后验证: 2026-10-13 · 分类: 系统与设置

06相关方案