JSON output different from the output of group object

Tagged: , ,

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of Ashish Patel Ashish Patel 5 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #37482
    Profile photo of Ashish Patel
    Ashish Patel
    Participant

    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
    Profile photo of Ashish Patel
    Ashish Patel
    Participant

    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

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.