具有 JSON 嵌套对象的 Powershell - 无法获取 属性 个对象中的 属性 个对象

Powershell with JSON nested objects - cannot get to a property of property of object

我是 Powershell 的新手,目前我正在尝试转换从 JSON 我从 Solr 下载的一些数据。

JSON 文件如下所示:

{
 "responseHeader": {"status":0, "QTime":2651},
"InitFailures":{}, 
"status":{
   "YX_SERVER.ONE_LOG.2020-11-07_07_49_33": {
         "name":"SERVER.ONE_LOG.2020-11-07_07_49_33",
            "index":{
               "sizeInBytes":69,
                "size":"69 bytes"}},
 "XY_SERVER.TWO_LOG.2020-11-08_09_52_11": {
         "name":"XY_SERVER.TWO_LOG.2020-11-08_09_52_11",
            "index":{
               "sizeInBytes":6487,
                    "size":"6487 bytes"}},
 "ZX_SERVER.THREE_LOG.2020-10-07_07_42_23": {
         "name":"SERVER.THREE_LOG.2020-10-07_07_42_23",
            "index":{
               "sizeInBytes":6977,
               "size":"6977 bytes"
                              }}}}

第二个状态行下方是带有大量参数(所有名称都不同)的服务器列表,我试图深入了解它,但需要有关嵌套数据的帮助。

我尝试了以下方法:

$list = Get-Content C:\Users\User\Download\cores.json - Raw |convertfrom-json |select-object -ExpandProperty status

然后 $list 向我显示了服务器列表,所需的数据在右栏中,但我无法直接访问它。如何构建 table 并计算总和,如下所示:

Name                                     Size(inbytes) 
YX_SERVER.ONE_LOG.2020-11-07_07_49_33    69
XY_SERVER.TWO_LOG.2020-11-08_09_52_11    6487
ZX_SERVER.THREE_LOG.2020-10-07_07_42_23  6977

Summary                                  Total size
                                         ?
$Content = Get-Content .\cores.json
$Data = $Content | ConvertFrom-Json
$Status = $Data.status
$Table = $Status.PSObject.Properties.Value | Foreach-Object {
    [pscustomobject]@{
        name = $_.name
        sizeInBytes = $_.index.sizeInBytes
    }
}
$Table

[pscustomobject]@{
    name = 'Total Size:'
    sizeInBytes = ($Table.sizeInBytes | Measure-Object -Sum).Sum
}

name                                  sizeInBytes
----                                  -----------
SERVER.THREE_LOG.2020-10-07_07_42_23         6977
XY_SERVER.TWO_LOG.2020-11-08_09_52_11        6487
SERVER.ONE_LOG.2020-11-07_07_49_33             69
Total Size:                                 13533