如何在PowerShell中使用名称对进程进行分组?

您可以根据进程的属性对其进行分组。在这里,我们将根据进程的名称对进程进行分组,它将显示正在运行的进程实例数。组对象命令对此很有用。

命令

以下命令将对对象进行分组,并根据其线程数对对象进行排序。

Get-Process |Group-Object Name | Select Name, Count |Sort-Object count - Descending

输出结果

Name                                                           Count
----                                                           -----
svchost                                                           91
chrome                                                            34
RuntimeBroker                                                     11
conhost                                                            6
Code                                                               6
WmiPrvSE                                                           6
dllhost                                                            4
RAVBg64                                                            4
powershell                                                         3
csrss                                                              2
fontdrvhost                                                        2
AcroRd32                                                           2
taskhostw                                                          2
SkypeBridge                                                        1
smartscreen                                                        1
smss                                                               1
sihost                                                             1
SkypeApp                                                           1
SkypeBackgroundHost                                                1
sppsvc                                                             1
StartMenuExperienceHost                                            1