Open mmusolesi opened 2 years ago
That's how PowerShell hashtables are designed. Just use ordered hashtables: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_hash_tables?view=powershell-7.3#creating-ordered-dictionaries
$NewINIContent = [ordered]@{"Category1"=$Category1;"Category2"=$Category2}
This issue could be closed. The Out-IniFile and Get-IniContent work with ordered hashables without issues.
Out-IniFile retunrs wrong ordered category.
Example: $Category1 = @{"Key1"="Value1";"Key2"="Value2"} $Category2 = @{"Key1"="Value1";"Key2"="Value2"} $NewINIContent = @{"Category1"=$Category1;"Category2"=$Category2} Out-IniFile -InputObject $NewINIContent -FilePath "C:\temp\settings.ini"
Output content: [Category2] Key1=Value1 Key2=Value2 [Category1] Key1=Value1 Key2=Value2