Public/Resources/Set-SIADatabaseStrongAccount.ps1

function Set-SIADatabaseStrongAccount {
    <#
    .SYNOPSIS
        Updates a database strong account in SIA.
    .DESCRIPTION
        Calls the Update strong account operation. Only the parameters you
        supply are sent. See New-SIADatabaseStrongAccount for the exact shape
        -AccountProperties expects, since it is genuinely polymorphic across
        database platforms.
    .PARAMETER Id
        The database strong account's ID, as returned by Get-SIADatabaseStrongAccount.
    .PARAMETER StoreType
        Where the strong account is stored: 'pam' or 'managed'.
    .PARAMETER Name
        A new display name for the strong account.
    .PARAMETER AccountProperties
        Platform-specific account properties. See New-SIADatabaseStrongAccount
        for the exact shape.
    .EXAMPLE
        Set-SIADatabaseStrongAccount -Id 'db-secret-01' -Name 'pg-admin-renamed'

        Renames the specified database strong account.
    .INPUTS
        psSIA.DatabaseStrongAccount
    .OUTPUTS
        psSIA.DatabaseStrongAccount
    .LINK
        https://api-docs.cyberark.com/secure-infra-access/docs/strong-account-apis-for-sia-databases
    #>

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

        [ValidateSet('pam', 'managed')]
        [string]$StoreType,

        [string]$Name,

        [hashtable]$AccountProperties
    )

    process {
        $body = @{}
        if ($PSBoundParameters.ContainsKey('StoreType')) { $body.storeType = $StoreType }
        if ($PSBoundParameters.ContainsKey('Name')) { $body.name = $Name }
        if ($PSBoundParameters.ContainsKey('AccountProperties')) { $body.accountProperties = $AccountProperties }

        if ($PSCmdlet.ShouldProcess($Id, 'Update database strong account')) {
            Invoke-SIARequest -Method PUT -Path "/api/database-strong-accounts/$Id" -Body $body |
                ConvertFrom-SIAResponse -TypeName 'psSIA.DatabaseStrongAccount'
        }
    }
}