JSON output different from the output of group object

This topic contains 1 reply, has 1 voice, and was last updated by  Ashish Patel 2 years, 1 month ago.

  • Author
  • #37482

    Ashish Patel

    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

  • #37484

    Ashish Patel

    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

You must be logged in to reply to this topic.