Public/Restore-P1ConfigVal.ps1

function Restore-P1ConfigVal {
    <#
    .Synopsis
    Copy in local files the PlannerOne Config files.

    .Description
    After the backup command, this command copy the PlannerOne backup configuration files and reset the PlannerOne web security for the tenant(s).
    
    .Parameter filesDir
    Input files config directory.

    .Parameter Tenant
    The target tenant. If you have more than one tenant, use "," to seperate all name like -tenant "tenant1,tenant2,tenant3"

    .Example
    # Restoring PlannerOne Config File
    Restore-P1ConfigVal -filesDir 'C:\tmp\PlannerOne_BackUp' -tenant Prod

    # Restoring PlannerOne with multitenant configuration
    Restore-P1ConfigVal -filesDir 'C:\tmp\PlannerOne-BackUp' -tenant 'Prod1,Debug,ValidTest2015,ValidTest2017'
    #>

    [cmdletbinding()]
    param( 
        [Parameter(Mandatory=$true)] [string] $filesDir,
        [Parameter(Mandatory=$true)] [string] $tenant
    )
    Process
    {
        Write-Section "Restore PlannerOne Configuration File from '$filesDir'"
        if(($filesDir -eq "") -OR !(test-path $filesDir )){
            Write-Error "Folder $filesDir not found"
            return
        }

        $OutDir = $env:ProgramData + "\PlannerOne"
        mkdir $OutDir -force
        Copy-Item $filesDir $OutDir -Recurse  -force
        Write-Verbose "Copy '$filesDir' to '$OutDir'."

        if($tenant.Contains(',')){
            $tenants = $tenant.Split(',').Trim()
            foreach($tnt in $tenants){
                Write-Verbose "Restore WebSecurity for tenant : $tnt"
                Restore-P1WebSecurity -tenant $tnt
            }

        }else{
            Write-Verbose "Restore WebSecurity for tenant : $tenant"
            Restore-P1WebSecurity -tenant $tenant
        }

        Write-OK "Restore ended"
    }    
}