Formatting Help

Hi PowerGuyz,
I am very new to this forum and also exploring PS too. Now I used to run Get-process command with memory values in MB format. I don’t want to change the property name, but the value I am expecting in MB. Now the problem is, the output is coming as custom property name. How should I manage the same?
Also please guide me if there is any shortcut to perform the same.
Here is the command:

Get-Process |select id, ProcessName, {$.pm /1mb -as [int]}, {$.vm /1mb -as [int]}, cpu -First 5|ft -AutoSize

Id ProcessName $.pm /1mb -as [int] $.vm /1mb -as [int] CPU

9524 AcroRd32 98 284 30.5137956
10564 AcroRd32 8 83 6.9732447
2188 armsvc 1 43 0.2496016
2164 CcmExec 45 224 36.7382355
2304 chrome 2 64 0.0156001


You want something like this

Get-Process |
select Id, ProcessName, 
@{Name = 'PM(M)'; Expression = {$ /1mb -as [int]}}, 
@{Name = 'VM(M)'; Expression = {$_.vm /1mb -as [int]}}, 
CPU -First 5 |
Format-Table -AutoSize

Dou you mean something like this:

Get-Process |
Select-Object -Property id, ProcessName, @{Name=‘PM’;Expression={$.pm /1mb -as [int]}}, @{Name=‘VM’;Expression={$.vm /1mb -as [int]}}, cpu -First 5 |
Format-Table -AutoSize

Hi Richard,

You are right, I want this exact same. But is it mandatory to do write @{Name = ‘PM(M)’; Expression = {$ /1mb -as [int]}} each time I need some conversation of MB/GB from small units? Is there any tricky way to perform that.


Yes, it’s mandatory.