Public/Backup-P1ConfigValue.ps1

function Backup-P1ConfigValue {
    <#
    .Synopsis
    Export PlannerOne configuration file to file.

    .Description
    Copy at destination path the PlannerOne configuration files to creat a backup folder.

    .Parameter OutDir
    The root directory path to use for export. .\p1EnvExport by default.

    .Example
    #Copy the cofiguration files to c:\tmp
    Backup-P1ConfigValue C:\tmp\Plannerone-Backup
    
    #>

    [cmdletbinding()]
    param(
        [string] $OutDir = ""
    )    
    Process {       

        Write-Section "Backup PlannerOne config file..."

        if ($OutDir -eq "") {
            $OutDir = ".\p1P1ConfigBackup"
        }

        if (!(Test-Path $OutDir)) {
            mkdir $OutDir | Out-Null
        }

        $sourcePath = $env:ProgramData + "\PlannerOne"
        write-verbose "Copy '$sourcePath' to '$OutDir'."
        Copy-Item $sourcePath $OutDir -Recurse -force
        Write-Section "Backup finished"
    }
}