I am new to Powershell and am trying to get repeating output compatible to be able to use ConvertTo-Html. I have a string in a PSCustomObject as well as some arrays. I am trying to denomalize using the following however the title property is not repeating as I would expect like this
Edit - output below
Title Comment
Hello World hello
Hello World bye
Edited as I missed the last select line (here I am expecting title to repeat on each line as the array expands)
$report = @()
$col1 = @()
$col1 += "hello"
$col1 += "bye"
$col2 = @()
$col2 += "blue"
$col2 += "green"
$col2 += "red"
$reportinfo = New-Object PSCustomObject
$reportinfo | Add-Member NoteProperty -name Title -value [String]"Hello World"
$reportinfo | Add-Member NoteProperty -name Comment -value $col1
$reportinfo | Add-Member NoteProperty -name Colour -value $col2
$report += $reportinfo
$report | select Title -ExpandProperty Comment
This returns the following output
hello
bye
If I use
Write-Output $report
I get the following
Title Comment Colour
----- ------- ------
[String]Hello World {hello, bye} {blue, green, red}
I have tried both with a string cast and without. Any ideas would be greatly appreciated.