Public/Get-M365LicenseAssignmentReport.ps1

<#
.SYNOPSIS
    Generates an HTML report of Microsoft 365 license assignments across the tenant.
    Connect first with Connect-RKGraph; this cmdlet uses the existing connection.
#>

function Get-M365LicenseAssignmentReport {
[CmdletBinding()]
param(
    [Parameter(Mandatory = $false)] [switch] $SendEmail,
    [Parameter(Mandatory = $false)] [string[]] $Recipient,
    [Parameter(Mandatory = $false)] [string] $From,
    [Parameter(Mandatory = $false)] [string] $ExportPath,
    [Parameter(Mandatory = $false)] [switch] $DebugMode
)

$ErrorActionPreference = 'Stop'
try {
    $ctx = Get-MgContext -ErrorAction SilentlyContinue
    if (-not $ctx) { throw 'Not connected to Microsoft Graph. Run Connect-RKGraph first.' }

    Invoke-M365LicenseReportCore -SendEmail:$SendEmail -Recipient $Recipient -From $From -ExportPath $ExportPath
}
catch { Write-Error "Error: $_"; throw $_ }
finally {
    # Session left connected; use Disconnect-RKGraph when done.
}
}