Author Posts

November 16, 2017 at 3:27 pm

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

Output:
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

Regards,
Roy.

November 16, 2017 at 3:59 pm

You want something like this

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

November 16, 2017 at 3:59 pm

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

?

November 16, 2017 at 4:17 pm

Hi Richard,

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

Regards
Roy.

November 16, 2017 at 4:18 pm

Yes, it's mandatory.