I'm creating a custom object with two properties. The first is a string, basically a key, and the second is the output of a function which returns an array. I'm then piping the results into Format-Table and grouping by the string property. What I'd like to see is each element of the array property on a separate row in the output. Instead, Format-Table is displaying the array on a single row.
Is there any way of formatting the output so each element of the array property is displayed on a separate row?
Here's some code that illustrates the problem:
function Get-Result([string]$lookup)
{
if ($lookup -eq "first")
{
return @("one", "two")
}
else
{
return @("three")
}
}
$a = "first", "second"
$a |
Select-Object @{Name="LookupValue"; Expression={$_}}, `
@{Name="Result"; Expression={Get-Result $_}} |
Format-Table -GroupBy LookupValue
And this is what it outputs:
LookupValue: first
LookupValue Result
----------- ------
first {one, two}
LookupValue: second
LookupValue Result
----------- ------
second three
What I'd like to see is:
LookupValue: first
LookupValue Result
----------- ------
first one
first two
LookupValue: second
LookupValue Result
----------- ------
second three