繁体   English   中英

如何从第一行输出中仅获取 postgres.exe 的 PID

[英]How do i get only PID of postgres.exe from the first row of output

我正在使用这个命令-

tasklist /FI "ImageName eq postgres.exe"

这是我得到的输出-

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
postgres.exe                  2300 Services                   0     19,752 K
postgres.exe                  2932 Services                   0      6,324 K
postgres.exe                  2992 Services                   0      8,660 K
postgres.exe                  3000 Services                   0      8,256 K
postgres.exe                  3008 Services                   0     11,128 K
postgres.exe                  3016 Services                   0      8,120 K
postgres.exe                  3024 Services                   0      7,756 K
postgres.exe                  3032 Services                   0      7,732 K
postgres.exe                  1684 Services                   0     20,732 K

回答评论和问题。

(Get-Process postgres)[0].ID

Get-Process获取名称为 postgres 的所有正在运行的进程

[0]抓取第一行

.ID抓取 PID 属性

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM