Fetch top 10 processes utilizing high CPU as shown in task manager

Copper Contributor


I have requirement where i have to fetch top 10 processes utilizing high cpu as shown in task manager.


Please guide me how to do it.


3 Replies

Hey @Prashantsahu, are you actually needing the "percentage" values like shown in the Task Manager (it is possible, just more work), or is it enough to still know the top 10 processes putting strain on the CPU?


Give this a go and see how you get on, start with Get-Process which returns all of the processes on the system.




Notice that there is a 'CPU(s)' property in the output, that's the "amount of processor time that the process has used on all processors, in seconds".


Next, you'll want to use Sort-Object to sort the list of processes using the most processor time. You'll note however that you can't sort by 'CPU(s)' as there's some trickery going on behind the scenes, but you can sort by 'CPU' and you'll also want to make this list descending so that the largest numbers are at the top.


Sort-Object -Property CPU -Descending


Finally, you only want the top 10, so use Select-Object and specify that you only want the first 10 objects.


Select-Object -First 10


Put that all together and you get something like this:


Get-Process | Sort-Object -Property 'CPU' -Descending | Select-Object -First 10



@Joshua King 

Thanks for the reply but I need the process name and id in percentage as shown in windows task manager.


Well it helped me. Thank you!