Powershell如何通过ProcessID获取ParentProcessID [英] Powershell how to get the ParentProcessID by the ProcessID

查看:42
本文介绍了Powershell如何通过ProcessID获取ParentProcessID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从拥有 ProcessID 的进程中获取 ParentProcessID 时遇到问题.我是这样尝试的,这就是它与 ProcessID 的工作方式:

I've problems to get the ParentProcessID from a Process where I have the ProcessID. I tried it like this, this is how it works with the ProcessID:

$p = Get-Process firefox
$p.Id

但是如果我用 ParentProcessID 尝试它,它不起作用:

But if I try it with the ParentProcessID, it doesn't work:

$p.ParentProcessId

有没有办法通过 ProcessID 获取 ParentProcessID?

Is there a way to get the ParentProcessID by the ProcessID?

推荐答案

这对我有用:

$p = Get-Process firefox
$parent = (gwmi win32_process | ? processid -eq  $p.Id).parentprocessid
$parent

输出如下:

1596

1596 是匹配的 ParentProcessID,我已经用 ProcessExplorer 检查过了.

And 1596 is the matching ParentProcessID I've checked it with the ProcessExplorer.

这篇关于Powershell如何通过ProcessID获取ParentProcessID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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