# Merge the POD PROFILE block into the cart's content\environ.ini, idempotently. # Any previous block between the two markers is replaced, so re-running is safe. $ini = 'C:\bt411\BT411_4.11.801\content\environ.ini' $prof = 'C:\bt411\BT411_4.11.801\content\podprofile.ini' $block = Get-Content $prof $keep = @() if (Test-Path $ini) { $inBlock = $false foreach ($line in (Get-Content $ini)) { if ($line -match '^# ==== BT411 POD PROFILE') { $inBlock = $true; continue } if ($line -match '^# ==== END BT411 POD PROFILE') { $inBlock = $false; continue } if (-not $inBlock) { $keep += $line } } } # Trim trailing blanks so repeated merges do not grow the file. while ($keep.Count -gt 0 -and $keep[-1].Trim() -eq '') { $keep = $keep[0..($keep.Count-2)] } ($keep + @('') + $block) | Set-Content $ini -Encoding ascii Write-Output "environ.ini: $((Get-Content $ini).Count) lines, profile keys:" Get-Content $ini | Select-String '^(BT_|L4)' | ForEach-Object { $_.Line }