Public/Compress-P1Logs.ps1

function Compress-P1Logs {
    <#
    .Synopsis
    Archive to zip the logs for a tenant
 
    .Description
    Zip all PlannerOne logs for tenant in a given file
 
    .Parameter Tenant
    The tenant name.
 
    .Parameters OutFile
    The zip file to write.
 
    .Example
    # Zip Prod logs
    Archive-P1Logs -Tenant Prod -OutFile c:\temp\prodlogs.zip
    #>

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

        $path = Get-LogPathFromTenant $Tenant
        if (!(Test-Path $path)) {
            Write-Warning "No logs to compress."
            return
        }

        Compress-Archive -Path $path -DestinationPath $OutFile
    }
}