Public/Restore-P1WebSecurity.ps1

function Restore-P1WebSecurity {
    <#
    .Synopsis
    Restore Web Application IIS configration based on security configuration (Authentication and SSL)
 
    .Description
    Configure IIS and register PlannerOne Web Application REST services with correct security configuration based on Authentication and SSL.
    Run Set-P1WebAuthentication and Set-P1WebSSL to change this parameters.
 
    .Parameter Tenant
    The target tenant.
 
    .Example
    # Restoring security
    Restore-P1WebSecurity -Tenant Prod
    #>

    [cmdletbinding()]
    param( 
        [Parameter(Mandatory=$true)]
        [string] $Tenant
    )
    Process
    {
        Write-Section "Restoring IIS and REST Web services for current security"
        if (!(Test-Tenant $Tenant)) {
            Write-Warning "Tenant $Tenant does not exist."
            Write-Warning "Operation canceled."
            return;
        }

        $ssl = Get-SSLConf $Tenant
        if ($ssl.Enable) {
            Write-Alert "Enabling SSL"
        } else {
            Write-Alert "Disabling SSL"
        }

        $disable = !($ssl.Enable)
        Set-WebSSLInternal -Tenant $Tenant -Enable:$ssl.Enable -Disable:$disable -SSLPort $ssl.Port -CertificateStore $ssl.Store -CertificateThumbprint $ssl.Thumbprint -HostedIP $ssl.IP -NoSave

        $authentication = Get-AuthenticationConf $Tenant
        Write-Alert "Applying authentication security: $authentication"
        $windows = $true
        $formular = $false
        if ($authentication -ne "Windows") {
            $windows = $false
            $formular = $true
        }

        Set-WebAuthenticationInternal -Tenant $Tenant -Windows $windows -Formular $formular -NoSave

        Write-Alert "Applying security on web services"
        Apply-WebConfOnWebServices $path

        Write-OK "Web security configuration restored for $Tenant"
    }    
}