如何使用 Select-object 在单个查询中获取进程和线程的详细信息?

How to use Select-object to get details of process and thread in single query?

当我执行以下查询时,我没有得到进程的名称,只得到线程的详细信息。

Get-Process -ProcessName Test | Select-Object @{Label='CMPNAME';Expression={$_.Name}}  -ExpandProperty Threads | Select-Object {$_.Id}

        OUTPUT :
                $_.Id
                -----
                8412
                10460
                10484
                10508
                10520
                10524

您需要告诉 Select-Object 要 select 哪些属性:

Get-Process -ProcessName Test | Select-Object @{Label='CMPNAME';Expression={$_.Name}}  -ExpandProperty Threads | Select-Object CMPNAME,Id