Public/Stop-OnePAMSession.ps1

function Stop-OnePAMSession {
    <#
    .SYNOPSIS
        Terminates an active OnePAM session.
    .DESCRIPTION
        Force-terminates a gateway session by its session ID.
    .PARAMETER SessionId
        The UUID of the session to terminate.
    .PARAMETER Force
        Skip confirmation prompt.
    .EXAMPLE
        Stop-OnePAMSession -SessionId "abc-123"
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)]
        [string]$SessionId,

        [switch]$Force
    )

    Assert-OpSafePathSegment -Value $SessionId -Label 'session ID'

    if (-not $Force -and -not $PSCmdlet.ShouldProcess($SessionId, 'Terminate session')) {
        return
    }

    $encoded = [System.Uri]::EscapeDataString($SessionId)
    Invoke-OpApi -Method POST -Path "/api/v1/sessions/$encoded/terminate" | Out-Null
    Write-Host "Session $SessionId terminated." -ForegroundColor Green
}