Implement root install loop using a switch

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

View file

@ -36,9 +36,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
@ -117,7 +120,9 @@ $null = New-Module {
};
Set-Stage ([SetupStage]::Configure);
} else {
break;
}
default {
$null = Import-Module PSWindowsUpdate;
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
@ -481,6 +486,7 @@ $null = New-Module {
}
}
}
}
function Invoke-WindowsInstallation([Context] $context) {
$Global:InformationPreference = "Continue";