I've been breaking my head over this for a while now. I run two pipelines to produce two arrays of tuples. Each tuple contains a (filename, property).
# create pipeline of (file, property1) tuples
$prop1 = Get-ChildItem *.prop1 -PipelineVariable fi |
Get-Content -Tail 150 |
Select-String -Pattern " Pattern1 (\d+)" |
ForEach-Object { $_.Matches } |
ForEach-Object { [System.Tuple]::Create($fi.Name, $_.Groups[1].Value) }
# create pipeline of (file, property2) tuples
$prop2 = Get-ChildItem *.prop2 -PipelineVariable fi |
Get-Content -Tail 5 |
Select-String -Pattern " Pattern2 (\d+)" | % { $_.Matches } |
ForEach-Object { $_.Matches } |
ForEach-Object { [System.Tuple]::Create($fi.Name, $_.Groups[1].Value) }
$result = ????
ConvertTo-Json $result
Now I would like to combine these tuple pipelines on filename to produce JSON output like:
[
{
'file':'filename1',
'prop1':'value1',
'prop2':'value2',
},
{
'file':'filename2',
'prop1':'value3',
'prop2':'value3',
}
]
How can I combine these pipelines to produce the desired output? Or am I making this more complicated than necessary?
$prop1and$prop2?