Implement root install loop using a switch

This commit is contained in:
Manuel Thalmann 2024-08-09 13:34:46 +02:00
parent 08e6c78d31
commit ae1c05ff35

View file

@ -35,9 +35,12 @@ $null = New-Module {
#>
function Start-InstallationLoop {
while (-not (Get-IsFinished)) {
if ($null -eq (Get-Stage)) {
switch (Get-Stage) {
($null) {
Set-Stage ([SetupStage]::Initialize);
} elseif ((Get-Stage) -eq ([SetupStage]::Initialize)) {
break;
}
([SetupStage]::Initialize) {
if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) {
Invoke-Hook "Install-Chocolatey" -Fallback {
# Install chocolatey
@ -116,7 +119,9 @@ $null = New-Module {
};
Set-Stage ([SetupStage]::Configure);
} else {
break;
}
default {
$null = Import-Module PSWindowsUpdate;
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
@ -476,6 +481,7 @@ $null = New-Module {
}
}
}
}
function Invoke-WindowsInstallation([Context] $context) {
$Global:InformationPreference = "Continue";