-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathUpdateScpAppConfig.ps1
40 lines (34 loc) · 1.11 KB
/
UpdateScpAppConfig.ps1
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
28
29
30
31
32
33
34
35
36
37
38
39
40
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$ConfigFile,
[Parameter(Mandatory = $true)]
[hashtable]$updateConfig
)
###########################################################
# Start - Initialization - Invocation, Logging etc
###########################################################
$VerbosePreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
$scriptPath = $MyInvocation.MyCommand.Path
$scriptDir = Split-Path $scriptPath
& "$scriptDir\..\init.ps1"
if(-not $?)
{
throw "Initialization failure."
exit -9999
}
###########################################################
# End - Initialization - Invocation, Logging etc
###########################################################
$appConfig = New-Object XML
$appConfig.Load($ConfigFile)
foreach($appSetting in $appConfig.configuration.appSettings.add)
{
if($updateConfig.ContainsKey($appSetting.key))
{
Write-InfoLog ("Updating " + $appSetting.key + " with new value") (Get-ScriptName) (Get-ScriptLineNumber)
$appSetting.value = $updateConfig[$appSetting.key]
}
}
$appConfig.Save($ConfigFile)