Skip to content

Instantly share code, notes, and snippets.

Created March 6, 2018 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/187178a4c67e415e8b4da7ecbef27859 to your computer and use it in GitHub Desktop.
Save anonymous/187178a4c67e415e8b4da7ecbef27859 to your computer and use it in GitHub Desktop.
$ini = @"
[INI-Version]
3
[Server Status]
"Online"
[Server Enabled]
True
[Server Host1]
"example.com"
[Server Host2]
"www.example.com";
[Enable Debug Logging]
True
[GUI Language]
"1033"
"@
$path = "$env:userprofile\test-(Get-Random).ini"
Set-Content -Path $path -Value $ini
$content = Get-Content -Path $path -Raw
$content2 = $content -replace '(?m)(?<key>^\[Server Host1\]\s+)(?<value>.*)','${key}my new value'
$content2
Remove-Item -Path $path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment