I have created one PowerShell file called Config.ps1 which contains variables which are used by all other PowerShell scripts. As per below sample, it contains commented section (for user's understanding) and real variable which are updated at run time.
<#$Global:DeploymentType = 'Full/Partial'#>
$Global:DeploymentType = ''
I am calling that config ps file in another script file. Like below
$ConfigFile = Split-Path -Path $PSCommandPath
$ConfigFile = $ConfigFile + "\Config.ps1"
."$ConfigFile"
$Config = Get-Content $ConfigFile
Do some tasks: 1.2.3 then update variables based on those task
$Config = $Config -creplace "DeploymentType = '[^']*'","DeploymentType = 'Full'"
$Config | Set-Content $ConfigFile -Force
Issue is that, both commented part and variable in config file is getting updated. I just want to update variable value and not the commented part. Any way to achieve that?