From ca2f3753c997ff7e8d2d866c915f710a485c35a7 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 21 Aug 2024 18:28:50 +0200 Subject: [PATCH] Prevent pauses in OneShot tasks --- scripts/Common/Scripts/Operations.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/Common/Scripts/Operations.ps1 b/scripts/Common/Scripts/Operations.ps1 index ad7743aa..94c218be 100644 --- a/scripts/Common/Scripts/Operations.ps1 +++ b/scripts/Common/Scripts/Operations.ps1 @@ -24,6 +24,7 @@ $null = New-Module { function Start-Operation { param( + [switch] $NonInteractive, [scriptblock] $Action ) @@ -33,7 +34,7 @@ $null = New-Module { } $Global:InOperation = $true; - $Global:ErrorActionPreference = 'Inquire'; + $Global:ErrorActionPreference = $NonInteractive.IsPresent ? 'Continue' : 'Inquire'; $env:WSLENV = "CONFIG_MODULE/p"; if ($env:CONFIG_MODULE) { @@ -156,7 +157,7 @@ $null = New-Module { ) try { - Start-Operation @PSBoundParameters; + Start-Operation -NonInteractive @PSBoundParameters; } catch { Set-Content -Path $errorPath -Value $Error;