September 2026
Five nearly identical scripts cost more than one with configuration
The situation
A script exists for a recurring task. Then a second use case comes along and, instead of generalising the script, someone copies and adapts it. A few years later five variants sit side by side that are eighty per cent identical.
The cost does not arise in the writing but afterwards. Every fix has to be applied five times, and on the fourth one someone forgets. In a project for a wholesaler these were five scripts for accessing different online catalogues. What differed were the address, the credentials, the data structure and the target directory. What was the same were authentication, error handling, logging and retry logic.
The solution
Everything that differs between the variants moves into a configuration file. What stays in the code is what is the same for all of them. Five scripts become one launcher and one INI file per catalogue.
[Katalog]
Name = Example
Adresse = https://catalogues.example.org/export
Benutzer = importservice
Zielverzeichnis = D:\Import\Example
[Verhalten]
WiederholungenMax = 3
WartezeitSekunden = 20
Reading it in PowerShell stays compact:
function Read-Konfiguration {
param([Parameter(Mandatory)][string] $Pfad)
$konfiguration = @{}
$abschnitt = ''
foreach ($zeile in Get-Content -Path $Pfad -Encoding UTF8) {
$zeile = $zeile.Trim()
if ($zeile -eq '' -or $zeile.StartsWith('#')) { continue }
if ($zeile -match '^\[(.+)\]$') {
$abschnitt = $Matches[1]
$konfiguration[$abschnitt] = @{}
continue
}
if ($zeile -match '^(.+?)\s*=\s*(.*)$') {
$konfiguration[$abschnitt][$Matches[1].Trim()] = $Matches[2].Trim()
}
}
return $konfiguration
}
Why INI and not JSON. For configurations maintained by a business department, INI is often the better choice. Not because the format is more modern, but because a missing bracket does not render the whole file unusable, and because anyone who has once edited a Windows setting by hand understands the structure. For configurations only developers touch, the opposite applies: there, JSON with a schema is better.
The outcome. Maintenance effort fell by around eighty per cent. A more important effect was another one: another catalogue could be connected without anyone having to call me. The business department creates a file and fills in four values.
When the rework is not worth it. With two variants, almost never, because the configuration layer itself needs maintaining and documenting. From three variants it usually pays off, from five it always does. And what does not belong in it is control flow: anyone expressing conditions and branches in INI files is rebuilding a programming language — without the tooling and without the error messages.