Public/Logging/Invoke-KritTcmCommand.ps1

<#
.SYNOPSIS
    Krit.TCM wrapper over Microsoft365DSC helper Invoke-M365DSCCommand
    (category: Logging, module: M365DSCErrorHandler).

.DESCRIPTION
    Auto-scaffolded wave .1514 by New-KritTcmFromM365DscHelpers.ps1.
    Thin delegating passthrough — logic stays in Microsoft365DSC upstream;
    Krit.TCM provides the friendly namespace + citation registration
    for HARD RULE 20 discipline.

    Install-Module Microsoft365DSC -Scope CurrentUser BEFORE calling.

.NOTES
    Wave .1514. Underlying cmdlet: Invoke-M365DSCCommand
    Category: Logging
    Module: M365DSCErrorHandler
    Params: 5
#>

function Invoke-KritTcmCommand {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)] [ScriptBlock] $ScriptBlock,
        [SwitchParameter] $SuppressNotFoundError,
        [SwitchParameter] $RetryOnNotFoundError,
        [Int32] $MaxRetries,
        [Int32] $BaseDelayInSeconds
    )

    if (-not (Get-Command -Name 'Invoke-M365DSCCommand' -ErrorAction SilentlyContinue)) {
        throw '[KritTcm] Invoke-M365DSCCommand not available — Install-Module Microsoft365DSC -Scope CurrentUser then re-run'
    }
    try {
        & 'Invoke-M365DSCCommand' @PSBoundParameters
    } catch {
        Write-Error ('[KritTcm/Invoke-KritTcmCommand] ' + 'Invoke-M365DSCCommand' + ' failed: ' + $_.Exception.Message)
        throw
    }
}