Public/Users/Get-KB4UserRiskScoreHistory.ps1

<#
.SYNOPSIS
Gets risk score history for a KnowBe4 user.

.DESCRIPTION
Retrieves risk score history for a specific KnowBe4 user. By default, KnowBe4
returns the standard history window. Use Full to request the complete available
history for that user.

.PARAMETER Id
The KnowBe4 user ID. This parameter also accepts the alias UserId.

.PARAMETER Full
Requests the full user risk score history instead of the default window.

.PARAMETER Raw
Returns the full PSKB4Reporting response envelope, including status code, headers,
request ID, URI, and response body.

.EXAMPLE
Get-KB4UserRiskScoreHistory -Id 12345

Gets the default risk score history for user 12345.

.EXAMPLE
Get-KB4UserRiskScoreHistory -UserId 12345 -Full

Gets the full risk score history for user 12345.

.OUTPUTS
PSCustomObject.
#>

function Get-KB4UserRiskScoreHistory
{
    [CmdletBinding()]
    param(
        [Parameter(Mandatory, ValueFromPipelineByPropertyName)]
        [Alias('UserId')]
        [int] $Id,

        [Parameter()]
        [switch] $Full,

        [Parameter()]
        [switch] $Raw
    )

    process
    {
        $query = @{}
        if ($Full)
        {
            $query['full'] = $true
        }

        $path = '/v1/users/{0}/risk_score_history' -f (Format-KB4PathValue -Value $Id)
        Get-KB4ResponseBody -Response (Invoke-KB4Request -Path $path -Query $query) -Raw:$Raw
    }
}