Powershell - Get multiple values ​​from a nested object

I am sure this is a very simple PowerShell question, but I have a JSON file that I load into a custom PowerShell object using ConvertFrom-Jsonand the following select-objectworks

$JsonContent.value | Select-Object -Property Name, @{Name = 'commit'; Expression = { $_.commit.author.date }}

I'm trying to get another column in a nested commit object, and the following does NOT work, so I hope someone can help me figure out how to get the second value from a nested commit object (I tried several options, but didn't work)

JsonContent.value | Select-Object -Property Name, @{Name = 'commit'; Expression = { $_.commit.author.date}, {$_.commit.commitId}}

thank

Scott

+4
source share
1 answer

Expression = ... script, , , , commit,

Expression = { $_.commit.author.date}, {$_.commit.commitId}  

Expression = { $_.commit.author.date, $_.commit.commitId}

commma 2-


, - , , .

Expression = { "{0} - {1}" -f $_.commit.author.date, $_.commit.commitId }

, commitId ,

... -Property Name, @{Name = 'commit'; Expression = { $_.commit.author.date}}, @{Name = 'commitId'; Expression = {$_.commit.commitId}} 
+4

Source: https://habr.com/ru/post/1651989/


All Articles