blob: 2858d0602010d4199e9f522223b5817620ea74f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
param([String] $inputDir, [String] $outputDir)
$templateFiles = Get-ChildItem -Path $inputDir -Filter "*-template.json" -File
foreach ($file in $templateFiles) {
$baseFilename = $file.BaseName + '.json'
$templateFilePath = $file.FullName
#remove the -template.json suffix
$outputFilePath = Join-Path -Path $outputDir -ChildPath $baseFilename.replace("-template","")
#substitute environment variables for file variables
Get-Content $templateFilePath | ForEach-Object {
if ($_ -match "\$\{((\w+))\}")
{
$_ -replace "\$\{(\w+)\}",$([Environment]::GetEnvironmentVariable($Matches[1]))
}
else
{
$_
}
} | Set-Content $outputFilePath
}
|