Created
June 19, 2023 07:47
-
-
Save Nillth/e557e0f2786c0696abb7404098faf82f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.NOTES | |
=========================================================================== | |
Created by: Marc Collins | |
Organization: Qlik Customer Success | |
Email: [email protected] | |
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