Public/Connectors/Update-SIAConnector.ps1

function Update-SIAConnector {
    <#
    .SYNOPSIS
        Upgrades or rotates the credentials of a SIA connector.
    .DESCRIPTION
        Wraps the connector Upgrade and Rotate operations. Exactly one of
        -Upgrade or -Rotate must be specified.
    .PARAMETER Id
        The connector's id, as returned by Get-SIAConnector.
    .PARAMETER Upgrade
        Upgrades the connector to the latest available version.
    .PARAMETER Rotate
        Rotates the connector's credentials.
    .EXAMPLE
        Get-SIAConnector | Where-Object { -not $_.isLatestVersion } | Update-SIAConnector -Upgrade

        Upgrades every connector that is not already on the latest version.
    .INPUTS
        psSIA.Connector
    .OUTPUTS
        None.
    .LINK
        https://api-docs.cyberark.com/secure-infra-access/docs/sia-connector-api
    #>

    [CmdletBinding(SupportsShouldProcess)]
    [Diagnostics.CodeAnalysis.SuppressMessage('PSReviewUnusedParameter', '',
        Justification = 'Upgrade and Rotate select the parameter set; the branch below reads ParameterSetName, not the switch values themselves.')]
    param(
        [Parameter(Mandatory, ValueFromPipelineByPropertyName)]
        [string]$Id,

        [Parameter(Mandatory, ParameterSetName = 'Upgrade')]
        [switch]$Upgrade,

        [Parameter(Mandatory, ParameterSetName = 'Rotate')]
        [switch]$Rotate
    )

    process {
        $action = if ($PSCmdlet.ParameterSetName -eq 'Upgrade') { 'upgrade' } else { 'rotate' }
        if ($PSCmdlet.ShouldProcess($Id, "Connector $action")) {
            Invoke-SIARequest -Method POST -Path "/api/connectors/$Id/$action" |
                ConvertFrom-SIAResponse -TypeName 'psSIA.Connector'
        }
    }
}