ScriptConfig icon indicating copy to clipboard operation
ScriptConfig copied to clipboard

HashTable on ini file not working in Powershell 7

Open Chouille opened this issue 3 years ago • 0 comments

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

}

`

Chouille avatar Feb 12 '21 08:02 Chouille