Public/Set-P1WebAuthentication.ps1

function Set-P1WebAuthentication {
    <#
    .Synopsis
    Set the PlannerOne Web server authentication mode.

    .Description
    Set the PlannerOne web application authentication mode to Windows authentication or Formular.
    Change REST web service security accordingly.
    The formular authentication enable anonymous authentication too.

    .Parameter Tenant
    The target tenant.

    .Parameter Windows
    Set the authentication to Windows.

    .Parameter Formular
    Set the authentication to Formular.

    .Example
    # Set Windows authentication
    Set-P1WebAuthentication -Tenant Prod -Windows

    .Example
    # Set Formular authentication
    Set-P1WebAuthentication -Tenant Prod -Formular

    #>

    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$true)]
        [string] $Tenant,
        [switch] $Windows,
        [switch] $Formular
    )
    Process
    {
        Write-Section "Setting Web Application authentication mode"
        if ($Windows -and $Formular) {
            Write-Warning "You can only choose one authentication option."
            return
        }

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

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

        Set-WebAuthenticationInternal -Tenant $Tenant -Windows:$Windows.IsPresent -Formular:$Formular.IsPresent
        Register-P1WebServices $Tenant
        if ($Windows) {
            $mode = "Windows"
        }
        else {
            $mode = "Formular"
        }

        Write-OK "Web authentication mode set to $mode for tenant $Tenant"
    }
}