Powershell获取具有ID进程的特定进程计数器 [英] Powershell Get a specific process counter with id process

查看:170
本文介绍了Powershell获取具有ID进程的特定进程计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为具有进程ID的进程获取特定的计数器。但是,我无法想到一种使用where-object匹配计数器过程的方法。
Like

I want to get specific counters for processes that I have process id's for. However I can't think of a way to use where-object to match the process for the counter. Like

Where Gc '\process(*)\id process -eq 456 gc '\process($name)\working set'

因此,使用进程ID检索名称并获取工作集(或达到该目的的东西)。

So use the process id to retrieve the name and get the working set (or something to that effect).

推荐答案

您可以获取进程名称的计数器,因此首先通过使用其ID,然后将进程名称嵌入计数器中。例如:

You can get counters for a process name so first get the process name by using its Id and then embed the process name in the counter. For example:

$id = # your process id
$proc = (Get-Process -Id $id).Name
Get-Counter -Counter "\Process($proc)\% Processor Time"

这篇关于Powershell获取具有ID进程的特定进程计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆