Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement