Powershell INI editing

后端 未结 1 1455
暗喜
暗喜 2021-01-12 16:31

I want to changing some values in an INI file. Unfortunately, I have keys in 2 different sections which share an identical name but need different values. My code uses the <

相关标签:
1条回答
  • 2021-01-12 17:01

    You are overcomplicating things. You can use Get-IniContent and Out-IniFile as follows:

    $ini = Get-IniContent c:\temp\ini.ini 
    $ini["posscreen"]["BitmapFile"] = "C:\Temp\FileC.bmp"  
    $ini | Out-IniFile -FilePath c:\temp\ini2.ini
    

    Note that if you want to overwrite the original file, you must add -Force to the Out-IniFile call.

    0 讨论(0)
提交回复
热议问题