O'Reilly logo

Pro Windows PowerShell by Hristo Deshev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.6. Sorting Collections

Do you want to sort your data according to some property's value? What about multiple properties? No problem: Sort-Object is your friend. Just give a list of properties to the cmdlet, and it uses them to sort your collection. Here is how you can sort your processes according to the sizes of their working sets:

PS> Get-Process | Sort-Object WS

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
      0       0        0         16     0               0 Idle
     28       1      248        524     4             364 smss
    713       0        0        532     4               4 System
    381      11    34492       1132  1520            1904 sqlservr

...

    347      18    22524      49612   312    34.55   2600 WINWORD
    431      11    66084      53300   157            1004 svchost
    848      39    59116      58532   277   101.20   2852 explorer
    159       8   101344      61032   193   141.91   2808 dwm

What ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required