$cs.File_CopyTree
Description
Section titled “Description”Recursively copies a directory tree from source to destination, creating destination if it doesn’t exist.
Syntax
Section titled “Syntax”$cs.File_CopyTree(string source, string destination, bool copySubDirs = true, bool overwrite = true)
Parameters
Section titled “Parameters”source (String)
Section titled “source (String)”Source folder to copy. Throws an error if it does not exist.
destination (String)
Section titled “destination (String)”Destination folder to copy to. Created automatically if it doesn’t exist.
copySubDirs (Boolean)
Section titled “copySubDirs (Boolean)”Also copy subfolders. Default is $true (full recursive copy).
overwrite (Boolean)
Section titled “overwrite (Boolean)”Overwrite existing files at the destination. Default is $true. If set to $false, any file that already exists at the destination is silently skipped and the rest of the copy still proceeds.
Return value
Section titled “Return value”None.
Example
Section titled “Example”$Source = Join-Path $global:Packageroot "Dummy"$cs.File_CopyTree($Source, "C:\Program Files\CapaInstaller\Dummy")Deploy a full configuration folder from the kit to the target machine, without overwriting any files an administrator may already have customized:
$Source = Join-Path $global:Packageroot "kit\config"$cs.File_CopyTree($Source, "C:\ProgramData\Contoso\App\config", $true, $false)Copy only the top-level files from a folder, leaving any subfolders behind, by setting copySubDirs=$false:
$Source = Join-Path $global:Packageroot "kit\templates"$cs.File_CopyTree($Source, "C:\ProgramData\Contoso\App\templates", $false)