I am trying to read a config file using PowerShell and then convert it to hashtable so that later I can retrieve the value by key.
Here is the code:
$installerConfigs = Get-Content $configFilePath | ConvertFrom-StringData
$installerConfigs
foreach ($h in $installerConfigs.GetEnumerator()) {
Write-Host "$($h.Name): $($h.Value)"
}
While the content of the config file is
admin_username = 'administrator' admin_password = '123456'
when I print the hashtable, it prints the value properly. But when I am iterating over it, it is unable to print anything.
Can someone point out what I am missing?
Just to mention, I have to use version 1.0 of PowerShell.