Help with EnhancedHTMLFragment - Group a list and table in a single HTMLFragment

I am trying to create a report that will loop thru two SQL tables then group the two tables together within a single EnhancedHTMLFragment. Currently they are listing separately ungrouped. The first SQL table is going to be a list, then the 2nd sub-table contains multiple rows. Is this possible?

foreach ($refRow in $deptRefsTable)
{
$params = @{‘As’=‘List’;
‘PreContent’=‘

Header

’;
‘Properties’=‘Property1’, ‘Property2’, ‘Property3’;}

$html_Table1+= Get-Table1 | ConvertTo-EnhancedHTMLFragment @params

$params = @{‘As’=‘Table’;
‘EvenRowCssClass’=‘even’;
‘OddRowCssClass’=‘odd’;
‘MakeTableDynamic’=$false;
‘Properties’=‘Property1’, ‘Property2’, ‘Property3’, ‘Property4’;}

$html_Table2 += Get-Table2 | ConvertTo-EnhancedHTMLFragment @params
}

$params = @{‘CssStyleSheet’=$style;
‘Title’=“System Report for $computer”;
‘PreContent’=“

System Report for $computer

”;
‘HTMLFragments’=@($html_Table1,$html_Table2)}
ConvertTo-EnhancedHTML @params |
Out-File -FilePath $filepath

 

What I currently get:

List A Property1 Property2 Property3
List B Property1 Property2 Property3
List C Property1 Property2 Property3
A-Property1-1 A-Property1-2 A-Property1-3 A-Property1-4
A-Property2-1 A-Property2-2 A-Property2-3 A-Property2-4
A-Property3-1 A-Property3-2 A-Property3-3 A-Property3-4
B-Property1-1 B-Property1-2 B-Property1-3 B-Property1-4
C-Property1-1 C-Property1-2 C-Property1-3 C-Property1-4
C-Property2-1 C-Property2-2 C-Property2-3 C-Property2-4
C-Property3-1 C-Property3-2 C-Property3-3 C-Property3-4
C-Property4-1 C-Property4-2 C-Property4-3 C-Property4-4
C-Property5-1 C-Property5-2 C-Property5-3 C-Property5-4
 

What I am hoping to see:

List A Property1 Property2 Property3
A-Property1-1 A-Property1-2 A-Property1-3 A-Property1-4
A-Property2-1 A-Property2-2 A-Property2-3 A-Property2-4
A-Property3-1 A-Property3-2 A-Property3-3 A-Property3-4
List B Property1 Property2 Property3
B-Property1-1 B-Property1-2 B-Property1-3 B-Property1-4
List C Property1 Property2 Property3
C-Property1-1 C-Property1-2 C-Property1-3 C-Property1-4
C-Property2-1 C-Property2-2 C-Property2-3 C-Property2-4
C-Property3-1 C-Property3-2 C-Property3-3 C-Property3-4
C-Property4-1 C-Property4-2 C-Property4-3 C-Property4-4
C-Property5-1 C-Property5-2 C-Property5-3 C-Property5-4

You’re building each piece as separate arrays, so it’s displaying it correctly. If you want them listed consecutively, then you need to build it as a string. Something like this:

$sb = [System.Text.StringBuilder]::new()

$services = Get-Service | Select -First 3
foreach ($service in $services) {
    $html1 = $service | ConvertTo-Html -Fragment -Property Status,Name | Out-String
    $html2 = $service | ConvertTo-Html -Fragment -Property DisplayName -As List | Out-String
    [void]$sb.Append( $html1 + '<br/><br/>' + $html2 )
}

$sb.ToString()

Thanks for the help! That did it.