Public/Resources/Set-SIAWindowsStrongAccount.ps1

function Set-SIAWindowsStrongAccount {
    <#
    .SYNOPSIS
        Updates a Windows strong account in SIA.
    .DESCRIPTION
        Calls the Update strong account operation (SecretDto schema). Only
        the parameters you supply are sent; see New-SIAWindowsStrongAccount
        for the exact shape -SecretData and -SecretDetails expect, since
        those parts of the schema are genuinely polymorphic.
    .PARAMETER Id
        The strong account's secret ID, as returned by Get-SIAWindowsStrongAccount.
    .PARAMETER SecretName
        A new display name for the strong account.
    .PARAMETER SecretType
        Where the strong account is stored: 'ProvisionerUser' or
        'PCloudAccount'.
    .PARAMETER SecretData
        The secret material. See New-SIAWindowsStrongAccount for the exact
        shape.
    .PARAMETER SecretDetails
        Target-specific details. See New-SIAWindowsStrongAccount for the
        exact shape.
    .PARAMETER IsActive
        Whether the strong account is active.
    .EXAMPLE
        Set-SIAWindowsStrongAccount -Id 'secret-01' -SecretName 'svc-app01-renamed'

        Renames the specified strong account.
    .INPUTS
        psSIA.WindowsStrongAccount
    .OUTPUTS
        psSIA.WindowsStrongAccount
    .LINK
        https://docs.cyberark.com/setup/latest/en/content/privileged-access/apis/dpa-strong-accounts-api.htm
    #>

    [CmdletBinding(SupportsShouldProcess)]
    [OutputType('psSIA.WindowsStrongAccount')]
    param(
        [Parameter(Mandatory, ValueFromPipelineByPropertyName)]
        [Alias('secret_id')]
        [string]$Id,

        [string]$SecretName,

        [ValidateSet('ProvisionerUser', 'PCloudAccount')]
        [string]$SecretType,

        [hashtable]$SecretData,

        [hashtable]$SecretDetails,

        [bool]$IsActive
    )

    process {
        $body = @{}
        if ($PSBoundParameters.ContainsKey('SecretName')) { $body.secret_name = $SecretName }
        if ($PSBoundParameters.ContainsKey('SecretType')) { $body.secret_type = $SecretType }
        if ($PSBoundParameters.ContainsKey('SecretData')) { $body.secret = $SecretData }
        if ($PSBoundParameters.ContainsKey('SecretDetails')) { $body.secret_details = $SecretDetails }
        if ($PSBoundParameters.ContainsKey('IsActive')) { $body.is_active = $IsActive }

        if ($PSCmdlet.ShouldProcess($Id, 'Update Windows strong account')) {
            Invoke-SIARequest -Method PUT -Path "/api/secrets/public/v1/$Id" -Body $body |
                ConvertFrom-SIAResponse -TypeName 'psSIA.WindowsStrongAccount'
        }
    }
}