- 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 display a few numbers of results in Get-Process in PowerShell?
To display only the first 5 processes you need to use –First parameter in the Select-Object pipeline statement. You can use multiple filter statements and later at last pipeline the –First command to display only a few results.
Command
Get-Process | Select -First 5
Output
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 498 26 9736 18624 2.27 6320 1 AcroRd32 624 51 112048 17036 44.84 8052 1 AcroRd32 572 32 22424 28740 5.63 6340 1 ApplicationFrameHost 156 9 1416 4984 0.08 4412 0 armsvc 208 13 10096 17012 10.17 23412 0 audiodg
Similarly, you can use the same command for WMI and CIM.
Get-WmiObject Win32_Process | Select -First 5 Get-CimInstance Win32_Process | Select -First 5
Command
To display the last certain number of results, you need to use –Last parameter in the Select-Object pipeline parameter.
Get-Process | Select -Last 5
Output
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 150 9 2904 7164 5.17 11356 0 WmiPrvSE 265 11 5968 10040 0.97 17448 0 WmiPrvSE 190 13 4648 9128 0.33 21412 0 WmiPrvSE 163 12 2032 6516 0.30 12224 1 WZQKPICK 340 20 5188 15152 39.91 4420 0 ZeroConfigService
Similarly, you can apply –Last for WMI and CIM commands.
Get-WmiObject Win32_Process | Select -Last 5 Get-CimInstance Win32_Process | Select -Last 5
Advertisements