After having received a splendid presentation on PowerShell from a couple of my colleagues (Rastix, Virtix and others…) it was time to write my first script myself. After fiddling around a couple of hours I came up with a script to list a top 10 of memory consuming processes on a remote computer:

function PrintMegs

get-wmiobject -class win32_process -computername $args[0] | Sort-Object vm -desc | Select-Object -first 10 | Format-Table ProcessName,@{Label=”VM (MB)”;Expression={PrintMegs($_.VM)}},@{Label=”WS (MB)”;Expression={PrintMegs($_.WS)}},Handles,ProcessID,Path -autosize

The script takes one input parameter; the name of the computer, it does work with “localhost” also though.

The hardest part was figuring out how to print the memroy details in MB, with no decimal places and in table format ;-)


Tagged with:
Posted in Scripting
IT Pro Summer GP
IT Pro Summer Grand Prix

IT Pro Summer Grand Prix

Microsoft Virtual Academy

MS Virtual Academy

Pro-Exchange / Pro-Lync / Pro-Office365

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 158 other followers

%d bloggers like this: