-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathCopy-ParameterFileCollection.ps1
More file actions
27 lines (26 loc) · 1.2 KB
/
Copy-ParameterFileCollection.ps1
File metadata and controls
27 lines (26 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function Copy-ParametersFileCollection {
[CmdletBinding(SupportsShouldProcess = $true)]
param (
[Parameter(Mandatory = $true)]
[string] $starterPath,
[Parameter(Mandatory = $true)]
[array]$configFiles
)
foreach ($configFile in $configFiles) {
$sourcePath = Join-Path $starterPath $configFile.templateParametersSourceFilePath
$destinationPath = Join-Path $starterPath $configFile.templateParametersFilePath
if (Test-Path $sourcePath) {
if ($PSCmdlet.ShouldProcess($sourcePath, "Copy")) {
# create destination folder if it does not exists
$destinationFolder = Split-Path -Path $destinationPath -Parent
if (-not (Test-Path $destinationFolder)) {
New-Item -ItemType Directory -Path $destinationFolder -Force | Out-String | Write-Verbose
}
Write-Verbose "Copying parameter file from $sourcePath to $destinationPath"
Copy-Item -Path $sourcePath -Destination $destinationPath -Recurse -Force | Out-String | Write-Verbose
}
} else {
Write-Warning "The file $sourcePath does not exist."
}
}
}