Implement the windows installation in a loop
This commit is contained in:
parent
401aa9e41c
commit
afb2d1be65
|
@ -11,38 +11,48 @@
|
||||||
. "$PSScriptRoot/../Scripts/SetupConfig.ps1";
|
. "$PSScriptRoot/../Scripts/SetupConfig.ps1";
|
||||||
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
||||||
|
|
||||||
|
<#
|
||||||
|
Finishes the installation of a running Windows machine.
|
||||||
|
#>
|
||||||
function Start-WindowsInstallation {
|
function Start-WindowsInstallation {
|
||||||
|
Start-InstallationLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Starts the installation loop.
|
||||||
|
#>
|
||||||
|
function Start-InstallationLoop {
|
||||||
. "$PSScriptRoot/../Scripts/Choco.ps1";
|
. "$PSScriptRoot/../Scripts/Choco.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/Hooks.ps1";
|
. "$PSScriptRoot/../Scripts/Hooks.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
|
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/SetupConfig.ps1";
|
. "$PSScriptRoot/../Scripts/SetupConfig.ps1";
|
||||||
|
|
||||||
while (-not (Get-IsFinished)) {
|
while (-not (Get-IsFinished)) {
|
||||||
|
switch (Get-Stage) {
|
||||||
|
$null {
|
||||||
|
Invoke-Hook "Start-Initialization" -Fallback {
|
||||||
|
if (-not ((Get-Command "choco") -and (Get-Command "refreshenv"))) {
|
||||||
|
# Install chocolatey
|
||||||
|
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
||||||
|
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));
|
||||||
|
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
|
||||||
|
refreshenv;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if (-not (Test-ChocoSoftware "powershell-core")) {
|
||||||
switch (Get-Stage) {
|
choco install -y powershell-core --install-arguments='"ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 REGISTER_MANIFEST=1 USER_MU=1 ENABLE_MU=1"';
|
||||||
$null {
|
Restart-Intermediate;
|
||||||
Invoke-Hook "Start-Initialization" -Fallback {
|
return;
|
||||||
if (-not ((Get-Command "choco") -and (Get-Command "refreshenv"))) {
|
}
|
||||||
# Install chocolatey
|
|
||||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
|
||||||
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));
|
|
||||||
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
|
|
||||||
refreshenv;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-ChocoSoftware "powershell-core")) {
|
if (Test-Path $env:PWSH_PATH) {
|
||||||
choco install -y powershell-core --install-arguments='"ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 REGISTER_MANIFEST=1 USER_MU=1 ENABLE_MU=1"';
|
Remove-Item -Recurse $env:PWSH_PATH;
|
||||||
Restart-Intermediate;
|
}
|
||||||
return;
|
};
|
||||||
}
|
}
|
||||||
|
Default {}
|
||||||
if (Test-Path $env:PWSH_PATH) {
|
|
||||||
Remove-Item -Recurse $env:PWSH_PATH;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
Default {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ using namespace System.Security.Principal;
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
[string] $configRoot = "HKLM:\Software\PortValhalla";
|
[string] $configRoot = "HKLM:\Software\PortValhalla";
|
||||||
[string] $stageOption = "Stage";
|
[string] $stageOption = "Stage";
|
||||||
|
[string] $finishedOption = "Finished";
|
||||||
[RegistryKey] $key = $null;
|
[RegistryKey] $key = $null;
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -99,4 +100,22 @@ $null = New-Module {
|
||||||
|
|
||||||
$null = Set-SetupOption $stageOption $Name;
|
$null = Set-SetupOption $stageOption $Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets a value indicating whether the setup has finished.
|
||||||
|
#>
|
||||||
|
function Get-IsFinished {
|
||||||
|
return [bool] (Get-SetupOption $finishedOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Sets a value indicating whether the setup has finished.
|
||||||
|
#>
|
||||||
|
function Set-IsFinished {
|
||||||
|
param(
|
||||||
|
$Value
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue