ScriptConfig
ScriptConfig copied to clipboard
HashTable on ini file not working in Powershell 7
Split not working correctly:
$key = $line.Split('[]=', 4)[0] $hash = $line.Split('[]=', 4)[1] $value = $line.Split('[]=', 4)[3]
I changed the hashtable switch case in ConvertFrom-ScriptConfigIni.ps1 like this as workaround :
`
'[*
]=' {
$property = $line.Split('=', 2)[0]
$value = $line.Split('=', 2)[1]
$key = $property.Split('[', 2)[0]
$hash = $property.Split('[', 2)[1].Replace("]","")
if ($null -eq $config[$key])
{
$config[$key] = @{}
}
$config[$key][$hash] = $value
break
}
`