Last active
March 18, 2019 12:57
-
-
Save mhudasch/cab9fa17e4e1608b242f48021902ec68 to your computer and use it in GitHub Desktop.
Gets the top 5 processes using the most ram. It shows the amount of memory and the overall percentage used.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Process | Group-Object -Property ProcessName | ForEach-Object { | |
$_ | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $env:ComputerName -Force; | |
$_ | Add-Member -MemberType NoteProperty -Name "MemoryUsageKB" -Value (($_.Group|Measure-Object WorkingSet -Sum).Sum / 1KB); | |
$_ | Add-Member -MemberType NoteProperty -Name "MemoryPercentageOnTotal" -Value ((100/(Get-CimInstance -ClassName "CIM_OperatingSystem" -Namespace "root/CIMv2").TotalVisibleMemorySize) * (($_.Group|Measure-Object WorkingSet -Sum).Sum / 1KB)); | |
$_; | |
} | Sort-Object -Descending -Property "MemoryUsageKB" | | |
Select-Object -First 5 | | |
Format-Table -Property "ComputerName","Name", @{n='Mem (KB)';e={'{0:N0}' -f $_.MemoryUsageKB};a='right'}, @{n='% on total';e={'{0:N2}%' -f $_.MemoryPercentageOnTotal};a='right'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment