Manage Processes in PowerShell ============================== Author: Momchil Ivanov Date : 2018.10.12 Introduction ------------ Manage processes in PowerShell. List Processes -------------- List processes: $ ps Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 3540 80 226880 36388 6 801,25 904 1 AcroRd32 525 23 9632 17960 0,86 5684 1 AcroRd32 721 36 19784 29152 9,02 10388 1 AcroRd32 782 59 158796 47620 35,81 11388 1 AcroRd32 215 16 2620 10856 0,30 2056 1 AdobeARM List all fileds in a table format: $ ps | ft * List all fileds in a list format: $ ps | fl * List specific fields: $ ps | ft -Property ID, WorkingSet, ProcessName, Path Sort list per ID: $ ps | sort -Descending ID Filter processes where WS is greater than some value, 2e7 in this case: $ ps | where {$_.WorkingSet -gt 2e7} Filter and sort: $ ps | where {$_.WorkingSet -gt 2e7} | sort -Descending WS Add a property to the list: $ ps | where {$_.WorkingSet -gt 2e7} | sort -desc WS | ft @{Label = "NPM(M)"; Expression = {[int]($_.NPM / 1MB)}}, @{Label = "PM(M)"; Expression = {[int]($_.PM / 1MB)}}, @{Label = "WS(M)"; Expression = {[int]($_.WS / 1MB)}}, @{Label = "VM(M)"; Expression = {[int]($_.VM / 1MB)}}, Id, ProcessName, Path -Auto Equvalent to top command on Unix like operating systems: $ While(1) {ps | sort -des cpu | select -f 15 | ft -a; sleep 1; cls} List of top 10 processes per memory consumption: $ ps | sort -desc WS | select -f 10 Total memory consumption: $ [int]($(ps | measure "WS" -Sum).Sum / 1MB) Total memory consumption of the top 10 processes: $ [int]($(ps | sort -desc WS | select -f 10 | measure "WS" -Sum).Sum / 1MB) Aliases uses here ----------------- fl Format-List ft Format-Table measure Measure-Object ps Get-Process sort Sort-Object where Where-Object References ---------- 1: https://docs.microsoft.com/en-us/powershell/scripting/getting-started/cookbooks/managing-processes-with-process-cmdlets?view=powershell-6