Public/Set-P1WebSSL.ps1

function Set-P1WebSSL {
    <#
    .Synopsis
    Enable or disable SSL for the PlannerOne Web server.
 
    .Description
    Enable or disable SSL for PlannerOne web application.
    Set certificate and binding on web site.
    Change REST web service security accordingly.
 
    .Parameter Tenant
    The target tenant.
 
    .Parameter Enable
    Enable SSL.
 
    .Parameter Disable
    Disable SSL.
 
    .Parameter SSLPort
    The port of binding. By default 443.
 
    .Parameter CertificateStore
    The store to use to get certificate. By default 'My'
 
    .Parameter CertificateFriendlyName
    The certificate friendly name to associate to binding. Exclusive option with thumbprint.
 
    .Parameter CertificateThumbprint
    The certificate thumbprint to associate to binding. Exclusive option with FriendlyName.
 
    .Parameter HostedIP
    The hosted ip associate to binding's certificate. 0.0.0.0 if not define.
 
    .Example
    # Enable SSL
    Set-P1WebSSL -Tenant Prod -Enable -CertificateFriendlyName server-prod-certif -Store Root
 
    .Example
    # Disable SSL on port 8443
    Set-P1WebSSL -tenant PROD -Disable -SSLPort 8443
 
    #>

    [cmdletbinding()]
    param( 
        [Parameter(Mandatory=$true)]
        [string] $Tenant,
        [switch] $Enable,
        [switch] $Disable,
        [int] $SSLPort,
        [string] $CertificateStore,
        [string] $CertificateFriendlyName,
        [string] $CertificateThumbprint,
        [string] $HostedIP
    )
    Process
    {
        Write-Section "Setting Web Application SSL"
        if ($Enable -and $Disable) {
            Write-Warning "You can only choose one option."
            return
        }

        if (!($Enable -or $Disable)) {
            Write-Warning "You need to choose one option."
            return
        }

        if (!(Test-Tenant $Tenant)) {
            Write-Warning "Tenant $Tenant does not exist."
            Write-Warning "Operation canceled."
            return;
        }

        Set-WebSSLInternal -Tenant $Tenant -Enable:$Enable.IsPresent -Disable:$Disable.IsPresent -SSLPort $SSLPort -CertificateStore $CertificateStore -CertificateFriendlyName $CertificateFriendlyName -CertificateThumbprint $CertificateThumbprint -HostedIP $HostedIP
        Register-P1WebServices $Tenant
        Write-OK "Web SSL enabled for tenant $Tenant"
    }
}