I am trying to convert below Json table to Json object
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "TimeGenerated",
"type": "datetime"
},
{
"name": "Computer",
"type": "string"
},
{
"name": "EventID",
"type": "int"
},
{
"name": "EventLevelName",
"type": "string"
},
{
"name": "RenderedDescription",
"type": "string"
}
],
"rows": [
[
"2022-01-10T09:25:41.837Z",
"Mycomputer",
2974,
"Error",
"The attribute value provided is not unique in the forest or partition. Attribute: servicePrincipalName Value=MSSQL/xxxxxxx.dev.com CN=xxxxxxxxx,OU=DBS,OU=SVC,OU=Servers,OU=UK,DC=dev,DC=xxxxx,DC=xxxxxx,DC=org Winerror: 8647 See http://go.microsoft.com/fwlink/?LinkID=279782 for more details on this policy. "
]
]
}
]
Expected output is as below, i have tried hard but no found how to do it
[
{
"TimeGenerated": "2022-01-10T09:25:41.837Z",
"Computer": "Mycomputer",
"EventID": "2974",
"EventLevelName": "Error",
"Rendered Description": "The attribute value provided is not unique in the forest or partition. Attribute: servicePrincipalName Value=MSSQL/xxxxxxx.dev.com CN=xxxxxxxxx,OU=DBS,OU=SVC,OU=Servers,OU=UK,DC=dev,DC=xxxxx,DC=xxxxxx,DC=org Winerror: 8647 See http://go.microsoft.com/fwlink/?LinkID=279782 for more details on this policy."
}
]
I have tried below script but not worked as expected, Need to get result as mentioned above
$affected_resources=
ForEach($Row in $affected_resources.Rows)
{
$TmpHash = [Ordered]@{} For($i = 0; $i -lt $Row.Length; ++$i )
{
$TmpHash.Add( $affected_resources.columns.name[$i], $Row[$i] )
} [PSCustomObject]$TmpHash
}