JSON output different from the output of group object

Welcome Forums General PowerShell Q&A JSON output different from the output of group object

This topic contains 1 reply, has 1 voice, and was last updated by

 
Participant
2 years, 7 months ago.

  • Author
    Posts
  • #37482

    Participant
    Points: 0
    Rank: Member

    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

  • #37484

    Participant
    Points: 0
    Rank: Member

    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

The topic ‘JSON output different from the output of group object’ is closed to new replies.