Skip to content

Instantly share code, notes, and snippets.

@Nillth
Created June 19, 2023 07:47
Show Gist options
  • Save Nillth/e557e0f2786c0696abb7404098faf82f to your computer and use it in GitHub Desktop.
Save Nillth/e557e0f2786c0696abb7404098faf82f to your computer and use it in GitHub Desktop.
<#
.NOTES
===========================================================================
Created by: Marc Collins
Organization: Qlik Customer Success
Email: Marc.Collins@qlik.com
Filename: Qlik-Sense_UpdateSettingsIni.ps1
===========================================================================
#>
$ValueName = 'EnableParqutFormat'
$RequiredValue = '1'
$SettingsIni = "$($env:ALLUSERSPROFILE)\Qlik\Sense\Engine\Settings.ini"
[string]$SettingsIniContent = Get-Content $SettingsIni -Raw
#Use Regex to find the property
$Regex = New-Object Regex -ArgumentList "(?<=$($ValueName)\=).*"
$value = $Regex.Match($SettingsIniContent).Value
#Add or Update
if ([string]::IsNullOrEmpty($Value)) {
$SettingsIniContent = "$($SettingsIniContent.Trim())`n$($ValueName)=$($RequiredValue)"
}
else {
$SettingsIniContent = $Regex.Replace($SettingsIniContent, $RequiredValue)
}
$SettingsIniContent | Set-Content $SettingsIni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment