Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get-Process with total memory usage

Tags:

$Processes = get-process -computername $tag1 | Group-Object -Property ProcessName foreach($Process in $Processes) {     $Obj = New-Object psobject     $Obj | Add-Member -MemberType NoteProperty -Name Name -Value $Process.Name     $Obj | Add-Member -MemberType NoteProperty -Name Mem -Value ($Process.Group|Measure-Object WorkingSet -Sum).Sum     $Obj }    

Currently, this displays memory usage in bytes, how can I change this to show something like:

76,592 KB

and also output everything that is autosized? (aligned to the left)

like image 764
Aaron Avatar asked Oct 24 '14 16:10

Aaron


People also ask

How do I find process memory usage?

You can check memory of a process or a set of processes in human readable format (in KB or kilobytes) with pmap command. All you need is the PID of the processes you want to check memory usage of. As you can see, the total memory used by the process 917 is 516104 KB or kilobytes.

How do I check memory usage on PID?

The ps command can also be used to monitor memory usage of individual processes. The ps v PID command provides the most comprehensive report on memory-related statistics for an individual process, such as: Page faults. Size of working segment that has been touched.

How do I see total memory usage in PowerShell?

In Windows PowerShell there is no exclusive cmdlet to find out the CPU and memory utilization rates. You can use the get-wmi object cmdlet along with required parameters to fetch the results.


2 Answers

Format-Table can show expressions and auto-size the columns to fit the results:

On 64 bits:

get-process -computername $tag1 | Group-Object -Property ProcessName |      Format-Table Name, @{n='Mem (KB)';e={'{0:N0}' -f (($_.Group|Measure-Object WorkingSet64 -Sum).Sum / 1KB)};a='right'} -AutoSize 

On 32 bits:

get-process -computername $tag1 | Group-Object -Property ProcessName |      Format-Table Name, @{n='Mem (KB)';e={'{0:N0}' -f (($_.Group|Measure-Object WorkingSet -Sum).Sum / 1KB)};a='right'} -AutoSize 
like image 99
Mike Zboray Avatar answered Sep 23 '22 03:09

Mike Zboray


Get-Process | Select-Object Name,@{Name='WorkingSet';Expression={($_.WorkingSet/1KB)}} 
like image 38
ojk Avatar answered Sep 25 '22 03:09

ojk