Public/Access/Get-SCAActiveSession.ps1

function Get-SCAActiveSession {
    <#
    .SYNOPSIS
        Lists active Secure Cloud Access sessions.
    .DESCRIPTION
        Calls GET /access/sessions to list every active session in the tenant, or
        GET /access/users/{userId}/sessions when -UserId is supplied to scope the results to one
        identity.
    .PARAMETER UserId
        Return only active sessions belonging to this user ID.
    .PARAMETER Session
        A psSCA.Session object or session name. Defaults to the current default session.
    .EXAMPLE
        Get-SCAActiveSession

        Lists every active session in the tenant.
    .EXAMPLE
        Get-SCAActiveSession -UserId 'a1b2c3d4-user-id'

        Lists active sessions for a specific user.
    .INPUTS
        None.
    .OUTPUTS
        psSCA.SessionInfo
    .LINK
        https://api-docs.cyberark.com/sca-api/docs/secure-cloud-access-apis
    #>

    [CmdletBinding()]
    [OutputType('psSCA.SessionInfo')]
    param(
        [Parameter()]
        [string]$UserId,

        [Parameter()]
        [object]$Session
    )

    if ($UserId) {
        Invoke-SCARequest -Session $Session -Service 'SCA' -Method GET -Path '/access/users/{userId}/sessions' `
            -PathParameters @{ userId = $UserId } -Operation 'Get-SCAActiveSession' -TypeName 'psSCA.SessionInfo'
    }
    else {
        Invoke-SCARequest -Session $Session -Service 'SCA' -Method GET -Path '/access/sessions' `
            -Operation 'Get-SCAActiveSession' -TypeName 'psSCA.SessionInfo'
    }
}