用 Get-Counter 采样性能计数器
把 CPU、磁盘、内存及自定义计数器读成对象。
运行 Get-Counter '\Processor(_Total)\% Processor Time' -SampleInterval 1 -MaxSamples 5。
01命令
命令
$ Get-Counter '\Processor(_Total)\% Processor Time' -SampleInterval 1 -MaxSamples 502作用说明
Get-Counter 把计数器数据返回为可过滤、比较或导出 CSV 的对象,并支持 -ComputerName 读取远程主机。这让阈值检查和趋势日志可脚本化,而非靠肉眼盯 PerfMon 图表。
03风险
!注意: 计数器名称本地化,引号必须正确;可用 -ListSet 在目标系统上发现名称。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- Get-Counter依据: Reads performance counter samples, including remote computers.
最后验证: 2026-10-13 · 分类: 系统与设置