我如何从第一行输出中只获得 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 属性