Skip to content

HashTable on ini file not working in Powershell 7 #6

@Chouille

Description

@Chouille

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

}

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions