{"id":64,"date":"2007-02-05T12:00:00","date_gmt":"2007-02-05T20:00:00","guid":{"rendered":"http:\/\/testblog.sapien.com\/index.php\/2007\/02\/05\/process-peeking\/"},"modified":"2007-02-05T12:00:00","modified_gmt":"2007-02-05T20:00:00","slug":"process-peeking","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2007\/02\/05\/process-peeking\/","title":{"rendered":"Process Peeking"},"content":{"rendered":"<p>I&#8217;ve been kicking around <a target=\"_blank\" href=\"http:\/\/www.powergadgets.com\">PowerGadgets<\/a> a bit more.&nbsp; 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.<\/p>\n<p>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&#8217;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.<\/p>\n<p><font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\"><font size=\"2\" face=\"Lucida Console\">Get-Process |sort workingset -desc<\/font> <\/font><\/p>\n<p>That&#8217;s pretty handy right there. But I only want to see the top 10 &#8220;offenders&#8221;. 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.<\/p>\n<p><font size=\"2\" face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-Process |sort workingset -desc | select -first 10 <\/font><\/p>\n<p>Getting better. But all I really care about is the Name and WorkingSet size. So I modify my expression to select just those properties.<\/p>\n<p><font size=\"2\" face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-Process |sort workingset -desc | select Name,Workingset -first 10 | format-table -auto<\/font><\/p>\n<p>Here&#8217; 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.  <\/p>\n<p>Speaking of output, let&#8217;s get to PowerGadgets. All that is left is for me to pipe everything I&#8217;ve come up with so far to the Out-Chart cmdlet.  <\/p>\n<p><font size=\"2\" face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-Process |sort workingset -desc | select Name,Workingset -first 10 `<br \/>| out-chart -floating -values Workingset -label Name<\/font>  <\/p>\n<p>&nbsp;This will produce a bar chart of the top 10 processes that looks something like this:<br \/>&nbsp;<span class=\"full-image-float-left\"><img decoding=\"async\" src=\"\/storage\/top10processes.png\" alt=\"top10processes.png\" \/><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Finally, I can add the -Refresh parameter to Out-Chart which will automatically update the chart. <\/p>\n<p><font size=\"2\" face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-Process |sort workingset -desc | select Name,Workingset -first 10 | out-chart -floating -values Workingset -label Name -refresh 00:02:00<\/font><\/p>\n<p>The -Refresh time is in Hour:Min:Sec. There are a number of cool things you can do with Out-Chart, but I&#8217;ll leave it to you to try them out.<br \/>&nbsp;<\/p>\n<div style=\"margin: 0px; padding: 0px; display: inline;\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:70566d00-d7ba-4a80-9dff-ccf762cb10a1\" class=\"wlWriterSmartContent\">Technorati tags: <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/PowerShell\">PowerShell<\/a>, <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/PowerGadgets\">PowerGadgets<\/a>, <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/Out-Process\">Out-Process<\/a>, <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/Out-Chart\">Out-Chart<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[25],"tags":[],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-windows-powershell"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}