Public/Groups/Get-KB4GroupRiskScoreHistory.ps1

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

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

.PARAMETER Id
The KnowBe4 group ID. This parameter also accepts the alias GroupId.

.PARAMETER Full
Requests the full group 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-KB4GroupRiskScoreHistory -Id 123

Gets the default risk score history for group 123.

.EXAMPLE
Get-KB4GroupRiskScoreHistory -GroupId 123 -Full

Gets the full risk score history for group 123.

.OUTPUTS
PSCustomObject.
#>

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

        [Parameter()]
        [switch] $Full,

        [Parameter()]
        [switch] $Raw
    )

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

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