@@ -50,20 +50,21 @@ function Set-Config {
5050 if ($null -ne $inputConfigItem ) {
5151 Write-Verbose " Found collection input config match for $inputConfigName "
5252 $inputConfigItemValue = $inputConfigItem.Value.Value
53- Write-Verbose " Input config item value type: $ ( $inputConfigItemValue.GetType ().FullName) "
54- $interfaces = $inputConfigItemValue.GetType ().ImplementedInterfaces
55- Write-Verbose " Input config item interfaces: $interfaces "
56- if (! $interfaces.Contains ([System.Collections.ICollection ])) {
57- Write-Error " Input config item $ ( $inputConfigName ) is not an array, but an index was specified."
58- throw " Input config item $ ( $inputConfigName ) is not an array, but an index was specified."
59- }
53+ $inputConfigItemValueType = $inputConfigItemValue.GetType ().FullName
54+ Write-Verbose " Input config item value type: $inputConfigItemValueType "
6055
6156 $indexString = $indexSplit [1 ].Replace(" `" " , " " ).Replace(" '" , " " )
6257 Write-Verbose " Using index $indexString for input config item $inputConfigName "
6358
6459 if ([int ]::TryParse($indexString , [ref ]$null )) {
6560 # Handle integer index for arrays
6661 Write-Verbose " Handling integer index for array"
62+
63+ if (! $inputConfigItemValueType.EndsWith (" []" )) {
64+ Write-Error " Input config item $ ( $inputConfigName ) is not an array, but an index was specified."
65+ throw " Input config item $ ( $inputConfigName ) is not an array, but an index was specified."
66+ }
67+
6768 $index = [int ]$indexString
6869 if ($inputConfigItemValue.Length -le $index ) {
6970 Write-Verbose " Input config item $ ( $inputConfigName ) does not have an index of $index ."
@@ -87,8 +88,15 @@ function Set-Config {
8788 } else {
8889 # Handle string index for maps
8990 Write-Verbose " Handling string index for map"
90- if ($inputConfigItemValue.ContainsKey ($indexString )) {
91- $inputConfigItemIndexValue = $inputConfigItemValue [$indexString ]
91+
92+ if (! $inputConfigItemValueType.EndsWith (" PSCustomObject" )) {
93+ Write-Error " Input config item $ ( $inputConfigName ) is not a map, but a key was specified."
94+ throw " Input config item $ ( $inputConfigName ) is not a map, but a key was specified."
95+ }
96+
97+ $mapItem = $inputConfigItemValue.PsObject.Properties | Where-Object { $_.Name -eq $indexString }
98+ if ($null -ne $mapItem ) {
99+ $inputConfigItemIndexValue = $mapItem.Value
92100 if ($null -ne $inputConfigItemIndexValue ) {
93101 $configurationValue.Value.Value = $inputConfigItemIndexValue
94102 continue
0 commit comments