Public/Connect/Get-KB4ReportingContext.ps1

<#
.SYNOPSIS
Gets the current KnowBe4 Reporting API connection context.

.DESCRIPTION
Returns a sanitized view of the current PSKB4Reporting connection context. The API token
is intentionally excluded from the output.

.EXAMPLE
Get-KB4ReportingContext

Shows whether the module is connected, along with the configured region, base
URI, and connection time.

.OUTPUTS
PSCustomObject.
#>

function Get-KB4ReportingContext
{
    [CmdletBinding()]
    param()

    if ($null -eq $script:KB4ReportingContext)
    {
        return [pscustomobject] @{
            IsConnected = $false
            Region      = $null
            BaseUri     = $null
            ConnectedAt = $null
        }
    }

    [pscustomobject] @{
        IsConnected = $true
        Region      = $script:KB4ReportingContext.Region
        BaseUri     = $script:KB4ReportingContext.BaseUri
        ConnectedAt = $script:KB4ReportingContext.ConnectedAt
    }
}