Process Peeking

I’ve been kicking around PowerGadgets a bit more.  The latest version has some new features I hope to write about in the near future. In the meantime, I want to demonstrate again how handy their gadgets are.

I run a lot of stuff on my computer, probably too much. Anyway, I often am morbidly curious about how much RAM different apps or processes are using. In PowerShell that is simple enough to discover with the Get-Process cmdlet. What I’m most interested in is the workingset size. By piping Get-Process to Sort, I can sort the output on a specific property and specify I want it in descending order.

Get-Process |sort workingset -desc

That’s pretty handy right there. But I only want to see the top 10 “offenders”. To accomplish that I continue to pass the objects to the Select cmdlet. This cmdlet has a parameter called -first which will display, naturally, the first X number of objects.

Get-Process |sort workingset -desc | select -first 10

Getting better. But all I really care about is the Name and WorkingSet size. So I modify my expression to select just those properties.

Get-Process |sort workingset -desc | select Name,Workingset -first 10 | format-table -auto

Here’ a little tip, however you type the properties in the Select statement, is how they will display as table headings. Make your property names case-proper and your output will look nicer.

Speaking of output, let’s get to PowerGadgets. All that is left is for me to pipe everything I’ve come up with so far to the Out-Chart cmdlet.

Get-Process |sort workingset -desc | select Name,Workingset -first 10 `
| out-chart -floating -values Workingset -label Name

 This will produce a bar chart of the top 10 processes that looks something like this:
 top10processes.png

 

 

 

Finally, I can add the -Refresh parameter to Out-Chart which will automatically update the chart.

Get-Process |sort workingset -desc | select Name,Workingset -first 10 | out-chart -floating -values Workingset -label Name -refresh 00:02:00

The -Refresh time is in Hour:Min:Sec. There are a number of cool things you can do with Out-Chart, but I’ll leave it to you to try them out.