-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tasks.ps1
40 lines (32 loc) · 1.16 KB
/
Tasks.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
$ErrorActionPreference = 'Stop'
$InformationPreference = 'Continue'
$VerbosePreference = 'SilentlyContinue'
$WarningPreference = 'Continue'
$DebugPreference = 'SilentlyContinue'
Function Invoke-GetSettingsFromFile {
Param ([string]$SettingsPath)
If($SettingsPath -and (Test-Path -LiteralPath $SettingsPath -PathType Leaf)) {
Return . $SettingsPath
}
Return @{}
}
Function Invoke-MergeSettings {
Param ([HashTable[]]$Settings)
$FinalSettings = @{}
ForEach ($SettingsHash in $Settings) {
#$SettingsHash.keys | ? {$_ -notin $FinalSettings.keys} | % {$FinalSettings[$_] = $SettingsHash[$_]}
$SettingsHash.keys | % {$FinalSettings[$_] = $SettingsHash[$_]}
}
Return $FinalSettings
}
Function Invoke-GetSettings {
Param
(
[string]$SettingsPath,
[string]$UserSettingsPath,
[HashTable]$CustomSettings = @{}
)
$DefaultSettings = Invoke-GetSettingsFromFile -SettingsPath $SettingsPath
$UserSettings = Invoke-GetSettingsFromFile -SettingsPath $UserSettingsPath
Return Invoke-MergeSettings @($DefaultSettings, $UserSettings, $CustomSettings)
}