Private/Export/Build-HtmlContent.ps1

function Build-HtmlContent {
    <#
    .SYNOPSIS
    Builds HTML table content from data with specified table ID.
     
    .DESCRIPTION
    Helper function that converts PowerShell objects to HTML table fragments.
    Injects the specified table ID for CSS styling and JavaScript filtering.
     
    .PARAMETER Data
    Array of objects to convert to HTML table.
     
    .PARAMETER TableId
    HTML ID attribute for the generated table element.
     
    .EXAMPLE
    $html = Build-HtmlContent -Data $summaryData -TableId "tblSummary"
     
    Returns HTML table fragment with id="tblSummary".
     
    .OUTPUTS
    String containing HTML table fragment.
    #>

    [CmdletBinding()]
    param(
        [Parameter()]
        [AllowNull()]
        [AllowEmptyCollection()]
        [object[]]$Data = @(),
        
        [Parameter(Mandatory)]
        [string]$TableId
    )
    
    if ($null -eq $Data -or $Data.Count -eq 0) {
        return "<p>No data available.</p>"
    }
    
    $html = $Data | ConvertTo-Html -Fragment
    $html = [regex]::Replace($html, '(?i)<table', "<table id='$TableId'", 1)
    
    return $html
}