Prevent pauses in OneShot tasks

This commit is contained in:
Manuel Thalmann 2024-08-21 18:28:50 +02:00
parent 93ae3c8e3e
commit c0f2c25ef6

View file

@ -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;