'Parsing through PowerShell API Response

I build a C# project which called an API and received a response as shown below and I looped through to determine how many times the System.State "New Value" was Resolved. We want to move this to run on a schedule via a pipeline so I am attempting to translate this into PowerShell.

I'm unfamiliar with how to create objects and loop through them in PowerShell as I'v shown in my C# project. Any guidance would be appreciated.

I've tried Invoke-RestMethod with | ConvertFrom-JSON:

$HistoryQueryResult = Invoke-RestMethod -Method Get -ContentType application/json -Uri $QueryUri -Headers $header | ConvertFrom-Json 

..but, I'm unsure after this point.

   var RootObjects = JsonConvert.DeserializeObject<WorkItemHistoryJson.Root>(result2);
            foreach (var item in RootObjects.value)
            {
                if (item.fields != null)
                {
                    if (item.fields.SystemState != null)
                    {                                          
                        if (item.fields.SystemState.newValue == StateToCheck)
                        {
                            TES_WorkItem.CountOfTestingRounds += 1;
                        }
                    }
                }                
            }

{
    "count": 6,
    "value": [
        {
            "id": 1,
            "workItemId": 226,
            "rev": 1,
            "revisedBy": {
                "id": "0e7735b9-cf6a-6468-82c1-81e6b092addd",
                "descriptor": "aad.MGU3NzM1YjktY2Y2YS03NDY4LTgyYzEtODFlNmIwOTJhZGRk"
            },
            "revisedDate": "2020-05-22T09:49:00.81Z",
            "fields": {
                "System.Id": {
                    "newValue": 226
                },
                "System.Reason": {
                    "newValue": "New"
                },
                "System.CreatedDate": {
                    "newValue": "2020-05-22T07:59:22.64Z"
                },
                "System.ChangedDate": {
                    "newValue": "2020-05-22T07:59:22.64Z"
                }
            }
        },
        {
            "id": 2,
            "workItemId": 226,
            "rev": 2,
            "revisedDate": "2020-05-22T09:49:04.45Z",
            "fields": {
                "System.Rev": {
                    "oldValue": 1,
                    "newValue": 2
                },        
                "System.State":{
                    "oldValue":"New",
                    "newValue":"Resolved"
                 }                     
            }
        }
    ]
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source