Public/Connectors/New-SIAConnectorInstallScript.ps1

function New-SIAConnectorInstallScript {
    <#
    .SYNOPSIS
        Generates a SIA connector installation script.
    .DESCRIPTION
        Calls the connector setup-script generation operation.
    .PARAMETER ConnectorOs
        The target operating system for the connector. Defaults to 'linux',
        matching CyberArk's own default.
    .PARAMETER ConnectorPoolId
        The connector pool to assign the new connector to.
    .PARAMETER ExpirationMinutes
        How long the generated script remains valid, in minutes.
    .PARAMETER ProxyHost
        Proxy host the connector should use to reach SIA.
    .PARAMETER ProxyPort
        Proxy port the connector should use to reach SIA.
    .PARAMETER WindowsInstallationPath
        Custom installation path, for Windows connectors only.
    .EXAMPLE
        New-SIAConnectorInstallScript -ConnectorOs linux

        Requests an installation script for a Linux connector.
    .EXAMPLE
        New-SIAConnectorInstallScript -ConnectorOs windows -ConnectorPoolId 'pool-1' -WindowsInstallationPath 'D:\SIA'

        Requests a Windows installation script that joins a specific connector pool.
    .INPUTS
        None.
    .OUTPUTS
        psSIA.ConnectorInstallScript
    .LINK
        https://api-docs.cyberark.com/secure-infra-access/docs/sia-connector-api
    #>

    [CmdletBinding()]
    [OutputType('psSIA.ConnectorInstallScript')]
    [Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '',
        Justification = 'Generates a downloadable script; it does not create or modify any tenant resource.')]
    param(
        [ValidateSet('windows', 'darwin', 'linux')]
        [string]$ConnectorOs = 'linux',

        [string]$ConnectorPoolId,

        [int]$ExpirationMinutes,

        [string]$ProxyHost,

        [int]$ProxyPort,

        [string]$WindowsInstallationPath
    )

    $body = @{ connector_os = $ConnectorOs }
    if ($PSBoundParameters.ContainsKey('ConnectorPoolId')) { $body.connector_pool_id = $ConnectorPoolId }
    if ($PSBoundParameters.ContainsKey('ExpirationMinutes')) { $body.expiration_minutes = $ExpirationMinutes }
    if ($PSBoundParameters.ContainsKey('ProxyHost')) { $body.proxy_host = $ProxyHost }
    if ($PSBoundParameters.ContainsKey('ProxyPort')) { $body.proxy_port = $ProxyPort }
    if ($PSBoundParameters.ContainsKey('WindowsInstallationPath')) { $body.windows_installation_path = $WindowsInstallationPath }

    Invoke-SIARequest -Method POST -Path '/api/connectors/setup-script' -Body $body |
        ConvertFrom-SIAResponse -TypeName 'psSIA.ConnectorInstallScript'
}