# $cs.Ini_ReadEntry

> Reads a value from a classic INI file. Returns an empty string if the section/variable combination isn't found in the file.

Source: https://docs.capaone.com/capainstaller/powerpacks/cs-ini-readentry/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

### Description

Reads a value from a classic INI file. Returns an empty string if the section/variable combination isn't found in the file. The maximum value length that can be read is 255 characters.

### Syntax

$cs.Ini\_ReadEntry(string filepath, string section, string variable)

### Parameters

#### filepath (String)

Path to the INI file. Throws a `FileNotFoundException` if this file doesn't exist.

#### section (String)

Section in the INI file to read from.

#### variable (String)

Variable name under the section to read.

### Return value

String, the value read, or an empty string if not found.

### Example

**PowerShell**

Read a migration flag to decide whether old settings still need to be migrated:

```powershell
$iniFile = "$env:ProgramData\Contoso\App\app.ini"
$version = $cs.Ini_ReadEntry($iniFile, "migration", "firstRunVersionFlag")
$cs.Job_WriteLog("firstRunVersionFlag is currently: $version")
```

Read a value and fall back to a sensible default when it comes back empty (not found):

```powershell
$iniFile = Join-Path $env:ProgramData "Contoso\App\settings.ini"
$logLevel = $cs.Ini_ReadEntry($iniFile, "logging", "level")
if ([string]::IsNullOrEmpty($logLevel)) {
  $logLevel = "Info"
  $cs.Job_WriteLog("logLevel not set in config, defaulting to '$logLevel'")
}
```

### Related functions

[$cs.Ini_WriteEntry](/capainstaller/powerpacks/cs-ini-writeentry/)
