Author Posts

April 10, 2016 at 1:30 am

Hello,
I am trying to get Process name and process Memory usage through powershell comamnd
get-process | Group-Object -Property ProcessName |
Format-Table Name, @{n='Mem (KB)';e={'{0:N0}' -f (($_.Group|Measure-Object WorkingSet -Sum).Sum / 1KB)};a='right'} -AutoSize

But when i pipe it with ConvertTo-Json the output is different.
I want the output in exact same way(Name and Mem (KB)) as it displays on screen but in json format.
Kindly help

April 10, 2016 at 3:27 am

Can be solved using

Get-Process | Group-Object -Property ProcessName |Select-object Name, @{n='Mem';e={(($_.Group|Measure-Object WorkingSet -Sum).Sum / 1KB)};}|ConvertTo-Json