Public/System/Set-SIASetting.ps1

function Set-SIASetting {
    <#
    .SYNOPSIS
        Updates SIA tenant feature settings.
    .DESCRIPTION
        Updates one feature's settings, or every feature at once when
        -FeatureName is omitted. By default a single feature is partially
        updated (PATCH); use -Replace to override the feature's settings
        entirely (PUT) instead. Requires the SiaAdmin role.
    .PARAMETER FeatureName
        The feature to update, e.g. 'SSHRecording' or 'StandingAccess'. Omit
        to update multiple features at once via -Body.
    .PARAMETER Body
        The request body. Its shape depends on the feature being updated -
        see the DpaConfigurationsDto family of schemas in the linked
        documentation.
    .PARAMETER Replace
        Overrides the feature's settings entirely instead of merging.
        Requires -FeatureName.
    .EXAMPLE
        Set-SIASetting -FeatureName 'SSHRecording' -Body @{ enabled = $true }

        Enables SSH recording, leaving other SSH recording settings untouched.
    .EXAMPLE
        Set-SIASetting -FeatureName 'SSHRecording' -Body $fullConfig -Replace

        Overrides the entire SSH recording configuration.
    .INPUTS
        None.
    .OUTPUTS
        psSIA.Setting
    .LINK
        https://api-docs.cyberark.com/secure-infra-access/docs/sia-settings-api
    #>

    [CmdletBinding(SupportsShouldProcess)]
    [OutputType('psSIA.Setting')]
    param(
        [Parameter(ValueFromPipelineByPropertyName)]
        [string]$FeatureName,

        [Parameter(Mandatory)]
        $Body,

        [switch]$Replace
    )

    process {
        if ($Replace -and -not $FeatureName) {
            throw '-Replace requires -FeatureName; the bulk settings endpoint only supports partial updates.'
        }

        $path = if ($FeatureName) { "/api/settings/$FeatureName" } else { '/api/settings' }
        $method = if ($Replace) { 'PUT' } else { 'PATCH' }
        $target = if ($FeatureName) { $FeatureName } else { 'all SIA features' }

        if ($PSCmdlet.ShouldProcess($target, "Update SIA settings ($method)")) {
            Invoke-SIARequest -Method $method -Path $path -Body $Body |
                ConvertFrom-SIAResponse -TypeName 'psSIA.Setting'
        }
    }
}