- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to sort the Processes based on their property name using PowerShell?
To sort the processes based on their various property names, Sort-Object command needs to pipeline and property name should be entered followed by it to the Get-Process cmdlet or WMI class or CIM instance.
Command
- To sort the property based on the CPU usage.
Get-Process | Sort-Object CPU
Output
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 0 0 60 8 0 0 Idle 112 6 1168 3588 0.02 2536 0 dasHost 104 7 2380 3972 0.02 1976 0 TeraCopyService 130 8 1436 6384 0.03 10236 0 SearchFilterHost 139 9 1736 7396 0.03 2412 1 browser_broker 86 5 976 2884 0.03 720 0 svchost 132 9 1636 4824 0.03 4144 0 svchost 153 11 1896 4920 0.03 7668 0 jhi_service 101 8 1292 5168 0.03 13892 1 conhost 117 8 1476 5508 0.05 6864 0 svchost 140 11 1796 5420 0.05 3792 0 svchost 118 7 6432 4200 0.05 4036 0 conhost 115 9 1924 3944 0.05 4428 0 WavesSysSvc64 103 8 1272 4976 0.06 15084 1 conhost 147 8 1492 5096 0.06 2484 0 svchost
Command
This data is sorted out in ascending order. To sort them in descending order you need to use –Descending parameter.
Get-Process | Sort-Object CPU -Descending
Output
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessNam ------- ------ ----- ----- ------ -- -- ---------- 6450 0 196 828 22,653.48 4 0 System 5200 572 328660 155208 9,775.30 4300 0 avp 2986 95 431368 326556 7,645.06 13656 1 chrome 1467 54 98552 90212 3,944.56 1280 1 dwm 781 91 191436 48772 2,499.55 20064 0 svchost 1036 162 583164 432000 2,240.81 22156 1 chrome 394 42 113940 91884 2,040.86 8884 1 chrome 249 14 109420 114352 1,948.33 2320 0 svchost 337 39 173372 69044 1,531.75 16716 1 chrome 797 82 597088 157860 1,458.78 16460 1 chrome 3544 144 105416 106836 1,357.77 7412 1 explorer 527 16 7584 21744 1,263.34 8620 1 SynTPEnh 723 70 52532 48524 1,209.48 19820 1 chrome 458 43 118340 108012 1,072.06 20544 1 chrome 2014 159 482772 381400 919.86 3492 1 WINWORD
Command
- To sort the processes with their memory usage, we need to use the property Working Set.
Get-Process | Sort-Object WorkingSet
Output
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 0 0 60 8 0 0 Idle 53 3 1156 484 0.31 568 0 smss 6435 0 196 832 22,714.41 4 0 System 756 69 66736 1464 33.98 9956 1 ksdeui 32 6 1800 1980 0.64 1080 0 fontdrvhost 1225 117 99616 2612 109.36 9964 1 avpui 86 5 976 2880 0.03 720 0 svchost 75 5 2488 3496 0.13 11244 1 cmd 112 6 1168 3588 0.02 2536 0 dasHost 85 6 1308 3924 1.92 4156 0 ibtsiva 115 9 1924 3944 0.05 4428 0 WavesSysSvc64 104 7 2380 3968 0.02 1976 0 TeraCopyService 78 6 1112 4160 0.11 10360 1 SynTPHelper 118 7 6432 4200 0.05 4036 0 conhost 118 7 6420 4280 0.08 6720 0 conhost 144 7 1328 4324 0.06 4208 0 svchost 218 7 1348 4452 0.09 4292 0 SynTPEnhService 750 27 1872 4540 10.70 800 0 csrss 277 7 1352 4680 0.64 2324 0 svchost 156 11 1428 4772 0.06 920 0 wininit 132 9 1636 4820 0.03 4144 0 svchost 207 7 1860 4900 1.39 1452 0 svchost
Command
In descending order,
Get-Process | Sort-Object WorkingSet -Descending
Output
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 0 0 3016 649952 556.25 2448 0 Memory Compression 1049 179 600324 481056 2,457.70 22156 1 chrome 2018 151 500136 379612 1,027.27 3492 1 WINWORD 1173 78 267104 254740 60.83 16220 1 powershell 2974 95 430988 211476 7,743.33 13656 1 chrome 427 77 180056 177696 147.28 22680 1 chrome 799 83 612832 170380 1,479.61 16460 1 chrome 631 64 139840 160844 161.98 676 1 Code 816 76 152144 136920 258.97 6708 0 pcdrwi 5111 569 332316 122720 9,988.89 4300 0 avp 533 32 208552 117884 67.02 13724 1 Code 3537 144 105788 113880 1,378.31 7412 1 explorer 1094 146 593628 111700 75.20 8180 0 SupportAssistAgent 246 14 105864 104592 1,994.08 2320 0 svchost 290 34 93956 95672 103.48 10388 1 chrome 305 32 72564 93792 7.66 16520 1 chrome 1509 88 110212 91688 25.42 18944 1 SearchUI
Similarly, you can pick any property and sort it in ascending or descending order.
- Related Articles
- How to group processes with their name in PowerShell?
- How to get all the processes on remote computers using PowerShell?
- How to get all the services based on their status in PowerShell?
- How to sort a JavaScript object list based on a property when the property is not consistent
- How to get the port number of the processes using PowerShell?
- How to get all the processes on the local computer with Get-Process command using PowerShell?
- Program to sort out phrases based on their appearances in Python
- How to get the running processes with the WMI object using PowerShell?
- How to get the running processes with the CIM instance using PowerShell?
- Program to sort numbers based on 1 count in their binary representation in Python
- How to get services based on start-type in PowerShell?
- How to change the local disk name using PowerShell?
- How to sort the output in PowerShell?
- How to get services based on multiple conditional parameters in PowerShell?
- How to delete registry key value (property) using PowerShell?

Advertisements