Powershell top processes script v2

I made some modifications to my top processes script that make it both better performing and more useful by providing more information. There is a noticeable delay when get-counter is called so rather than staring at a black screen waiting for the results from this call, I modified the script such that the previous results are displayed on screen while get-count is called and sends it output to a variable. At the same time I added counters for total CPU usage and idle cpu percentage. It is still a one-liner, but rather cumbersome as such, I may break it up for a future post:

while (1)  { $tot = get-counter "\Processor(_total)\% processor time"; $idl = get-counter "\Process(idle)\% processor time"; $Proc = Get-counter "\Process(*)\% processor time"; $p2 = $Proc.CounterSamples | where {$_.instanceName -ne "idle"} | where {$_.instanceName -ne "_total"}; cls; $tot.countersamples; $idl.countersamples;  $p2| sort -desc CookedValue |select -first 17; sleep -seconds 3;}
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s