Public/Set-P1Tenant.ps1

function Set-P1Tenant {
    <#
    .Synopsis
    Modify a tenant configuration.
 
    .Description
    Modify the configuration of an existing PlannerOne tenant.
 
    .Parameter Tenant
    The tenant name.
 
    .Parameter WebServicePort
    The port to be used by AppServer for REST API.
 
    .Parameter RemotingPort
    The port to be used by AppServer for Remoting API.
 
    .Parameter WebPort
    The customized port to be used by WebServer site.
 
    .Parameter WebAppName
    The customized name to use for web application.
 
    #>

    [cmdletbinding()]
    param(      
        [Parameter(Mandatory=$true)]
        [string] $Tenant,
        [int] $RemotingPort,
        [int] $WebServicePort,
        [int] $WebPort,
        [string] $WebAppName
    )
    Process
    {
        if (!(Test-Tenant $Tenant)) {
            Write-Warning "Tenant $Tenant does not exist."
            Write-Warning "Operation canceled."
            return
        }

        $tenantInfo = Get-TenantInfo $Tenant
        if ($tenantInfo -eq $null) {
                Write-Warning "No tenant information available"
                Write-Warning "Configuration cancel"
                return
        }

        Modify-TenantInfo $Tenant $RemotingPort $WebServicePort $WebPort $WebAppName
                
        $serviceName = Get-ServiceNameFromTenant $Tenant
        Write-Output "Restarting PlannerOne service $serviceName..."

        Stop-Service -Name $ServiceName -Force

        Write-Output "Waiting 5 seconds for service to really stop."
        Start-Sleep -seconds 5
        
        Start-Service -Name $serviceName
        Write-OK "Configuration done"
    }
}