Public/Stop-P1Tenant.ps1

function Stop-P1Tenant {
    <#
    .Synopsis
    Stop a PlannerOne tenant
 
    .Description
    Stop a PlannerOne tenant by restarting web application and service.
 
    .Parameter Tenant
    The target tenant.
#>

    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$true)]
        [string] $Tenant
    )
    Process
    {
        Write-Section "Stopping tenant $Tenant"
        if (!(Test-Tenant $Tenant)) {
            Write-Warning "Tenant $Tenant does not exist."
            Write-Warning "Operation canceled."
            return;
        }

        $info = Get-P1Tenant $Tenant
        $webApp = Get-P1WebApplication $Tenant
        if ($webApp -eq $null) {
                Write-KO "Cannot find the web application for tenant $Tenant"
                return
        }
        
        Stop-P1ServiceInternal $info
        Stop-P1WebInternal $webApp

        Write-OK "Tenant $Tenant stopped"
    }
}