具有总内存使用量的 Get-Process [英] Get-Process with total memory usage
本文介绍了具有总内存使用量的 Get-Process的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$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)
推荐答案
Format-Table 可以显示表达式并自动调整列的大小以适应结果:
Format-Table can show expressions and auto-size the columns to fit the results:
64 位:
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
32 位:
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
这篇关于具有总内存使用量的 Get-Process的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文