Given this JSON
{"name":"//iam.googleapis.com/projects/aw-b9a-8231-4086-a297-ca0/serviceAccounts/1081069135974252","asset_type":"iam.googleapis.com/ServiceAccount","resource":{"version":"v1","discovery_document_uri":"https://iam.googleapis.com/$discovery/rest","discovery_name":"ServiceAccount","parent":"//cloudresourcemanager.googleapis.com/projects/1090951556423","data":{"email":"default@aw-d1eb6b9a-8231-4086-a297-ca0.iam.gserviceaccount.com","name":"projects/aw-d1eb6b9a-8231-4086-a297-ca0/serviceAccounts/default@aw-d1eb6b9a-8231-4086-a297-ca0.iam.gserviceaccount.com","oauth2ClientId":"108102635374252","projectId":"aw-d1eb6b9a-8231-4086-a297-ca0","uniqueId":"108108526913531974252"}},"ancestors":["projects/1090951556423","folders/940897400840","folders/140924730741","organizations/437515948226"],"update_time":"2021-02-08T18:23:18Z"}
I'm trying to use the following snippet from Windows command window,
powershell -nologo -executionpolicy bypass "& {foreach($line in Get-Content temp.txt) {ConvertFrom-Json -InputObject $line}}" > temp2.txt
To get the retrieved keys and values into a file (temp2.txt). However, ConvertFrom-Json only gets the first hierarchic level of the JSON, now down in the data
array. I have tried -Depth 3
but get this error:
At line:1 char:81
+ ... ontent temp.txt) {ConvertFrom-Json -InputObject $line -Depth 4 -Comp ...
+ ~~~~~~
+ CategoryInfo : InvalidArgument: (:) [ConvertFrom-Json], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.ConvertFromJsonCommand```