Skip to content

$cs.Ini_WriteEntry

Writes or updates a value in an INI file’s section. If the INI file (or its parent folder) doesn’t exist yet, it is created automatically.

$cs.Ini_WriteEntry(string filepath, string section, string variable, string value)

Path to the INI file. Created automatically, along with its parent folder, if it doesn’t already exist.

Section in the INI file to write to.

Variable under the section to create or update.

Value to write.

None

Disable an application’s built-in update check after installation:

Terminal window
$iniFile = "$env:ProgramData\Contoso\App\app.ini"
$cs.Ini_WriteEntry($iniFile, "updates", "checkForUpdates", "false")

Write a first-run marker for the PowerPack itself, in a config file that is created on demand:

Terminal window
$stateFile = Join-Path $env:ProgramData "Contoso\App\state.ini"
$cs.Ini_WriteEntry($stateFile, "deployment", "firstRunCompleted", "true")
$cs.Job_WriteLog("First-run marker written to $stateFile")

Update a version string in a config file after a successful upgrade:

Terminal window
$iniFile = Join-Path $env:ProgramData "Contoso\App\settings.ini"
$cs.Ini_WriteEntry($iniFile, "app", "installedVersion", $global:AppRelease)
$cs.Job_WriteLog("Recorded installed version $global:AppRelease in $iniFile")

$cs.Ini_ReadEntry