From 94c6b2bb213c04f1ee6dcb74e47b45c02e21eaff Mon Sep 17 00:00:00 2001 From: rmeijer_huizehetoost Date: Wed, 29 Oct 2025 11:52:10 +0100 Subject: [PATCH] fix3 apps --- main-menu.ps1 | 34 ++++++++++++++++++++++++++++++++-- scripts/install-apps.cmd | 17 ++++++++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/main-menu.ps1 b/main-menu.ps1 index b01864e..f7c2dce 100644 --- a/main-menu.ps1 +++ b/main-menu.ps1 @@ -298,7 +298,22 @@ function Install-MedewerkersApps { # Parse de PowerShell array uit het bestand (multiline pattern) if ($content -match '(?s)\$apps\s*=\s*@\s*\((.*?)\)') { $appsString = $matches[1] - $apps = $appsString -split ',' | ForEach-Object { $_.Trim().Trim('"').Trim("'") } | Where-Object { $_ -ne '' } + # Split on comma or newline, then clean up each item + $apps = @() + $lines = $appsString -split '[,\r\n]+' + foreach ($line in $lines) { + $item = $line.Trim() + # Skip empty lines + if ([string]::IsNullOrWhiteSpace($item)) { continue } + # Remove quotes from both ends (handle both single and double quotes) + $item = $item -replace '^["'']+', '' -replace '["'']+$', '' + # Remove any remaining whitespace and newlines + $item = $item.Trim().Replace("`r", '').Replace("`n", '') + # Only add if not empty + if ($item -and $item -ne '') { + $apps += $item + } + } } if ($apps.Count -eq 0) { @@ -398,7 +413,22 @@ function Install-GastenApps { # Parse de PowerShell array uit het bestand (multiline pattern) if ($content -match '(?s)\$apps\s*=\s*@\s*\((.*?)\)') { $appsString = $matches[1] - $apps = $appsString -split ',' | ForEach-Object { $_.Trim().Trim('"').Trim("'") } | Where-Object { $_ -ne '' } + # Split on comma or newline, then clean up each item + $apps = @() + $lines = $appsString -split '[,\r\n]+' + foreach ($line in $lines) { + $item = $line.Trim() + # Skip empty lines + if ([string]::IsNullOrWhiteSpace($item)) { continue } + # Remove quotes from both ends (handle both single and double quotes) + $item = $item -replace '^["'']+', '' -replace '["'']+$', '' + # Remove any remaining whitespace and newlines + $item = $item.Trim().Replace("`r", '').Replace("`n", '') + # Only add if not empty + if ($item -and $item -ne '') { + $apps += $item + } + } } if ($apps.Count -eq 0) { diff --git a/scripts/install-apps.cmd b/scripts/install-apps.cmd index 3dfbbcf..42bffb2 100644 --- a/scripts/install-apps.cmd +++ b/scripts/install-apps.cmd @@ -136,7 +136,22 @@ try { # Parse the PowerShell array from the file (multiline pattern) if ($content -match '(?s)\$apps\s*=\s*@\s*\((.*?)\)') { $appsString = $matches[1] - $apps = $appsString -split ',' | ForEach-Object { $_.Trim().Trim('"').Trim("'") } | Where-Object { $_ -ne '' } + # Split on comma or newline, then clean up each item + $apps = @() + $lines = $appsString -split '[,\r\n]+' + foreach ($line in $lines) { + $item = $line.Trim() + # Skip empty lines + if ([string]::IsNullOrWhiteSpace($item)) { continue } + # Remove quotes from both ends (handle both single and double quotes) + $item = $item -replace '^["'']+', '' -replace '["'']+$', '' + # Remove any remaining whitespace and newlines + $item = $item.Trim().Replace("`r", '').Replace("`n", '') + # Only add if not empty + if ($item -and $item -ne '') { + $apps += $item + } + } } Write-Host "✓ App lijst geladen: $($apps.Count) apps gevonden" -ForegroundColor Green