Public/Reports/New-NMMReport.ps1

function New-NMMReport {
    <#
    .SYNOPSIS
        Initializes a new NMM report builder for multi-section reports.
 
    .DESCRIPTION
        Creates an NMMReportBuilder object that can be used to build
        complex reports with multiple sections, charts, and custom content.
        Use Add-NMMReportSection to add data sections and Export-NMMReport
        to generate the final HTML file.
 
    .PARAMETER Title
        Main title of the report. Required.
 
    .PARAMETER Subtitle
        Optional subtitle displayed below the title.
 
    .PARAMETER LogoUrl
        Optional URL for a custom logo. If not specified, uses the
        embedded Nerdio logo (base64).
 
    .PARAMETER Theme
        Report theme: 'light' or 'dark'. Default is 'light'.
 
    .PARAMETER FooterText
        Custom footer text. Default is "Generated by NMM-PS Module".
 
    .PARAMETER Metadata
        Optional hashtable of metadata to include in the report.
 
    .EXAMPLE
        $report = New-NMMReport -Title "Monthly AVD Report" -Subtitle "December 2024"
        $report | Add-NMMReportSection -Title "Host Pools" -Data $pools -ShowChart
        $report | Export-NMMReport -OutputPath "./report.html"
 
    .EXAMPLE
        New-NMMReport -Title "Device Compliance" -Theme dark |
            Add-NMMReportSection -Title "Devices" -Data $devices -ShowChart -ChartType pie -PassThru |
            Export-NMMReport -OutputPath "./devices.html" -OpenInBrowser
 
    .OUTPUTS
        NMMReportBuilder - The report builder object for pipeline operations.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true, Position = 0)]
        [string]$Title,

        [Parameter()]
        [string]$Subtitle,

        [Parameter()]
        [string]$LogoUrl,

        [Parameter()]
        [ValidateSet('light', 'dark')]
        [string]$Theme = 'light',

        [Parameter()]
        [string]$FooterText,

        [Parameter()]
        [hashtable]$Metadata
    )

    $report = [NMMReportBuilder]::new($Title)

    if ($Subtitle) { $report.Subtitle = $Subtitle }
    if ($Theme) { $report.Theme = $Theme }
    if ($FooterText) { $report.FooterText = $FooterText }
    if ($Metadata) { $report.Metadata = $Metadata }

    # Set logo
    if ($LogoUrl) {
        $report.SetLogo('url', $LogoUrl)
    }
    else {
        $logoBase64 = Get-NMMReportAssets -AssetType 'Logo'
        $report.SetLogo('base64', $logoBase64)
    }

    return $report
}