From 401aa9e41c75bfa7663cb34169b0692085b43caa Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 31 Jul 2024 15:52:41 +0200 Subject: [PATCH] Recreate script to first install `pwsh` --- scripts/Windows/OS/Install.ps1 | 42 ++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index d5a34e62..75c019e2 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -4,11 +4,49 @@ . "$PSScriptRoot/Manage.ps1"; . "$PSScriptRoot/Upgrade.ps1"; . "$PSScriptRoot/User/Install.ps1"; +. "$PSScriptRoot/../Scripts/Choco.ps1"; . "$PSScriptRoot/../Scripts/Context.ps1"; +. "$PSScriptRoot/../Scripts/Hooks.ps1"; +. "$PSScriptRoot/../Scripts/PowerManagement.ps1"; +. "$PSScriptRoot/../Scripts/SetupConfig.ps1"; . "$PSScriptRoot/../Software/Firefox/Install.ps1"; -function Invoke-WindowsInstallation([Context] $context) -{ +function Start-WindowsInstallation { + . "$PSScriptRoot/../Scripts/Choco.ps1"; + . "$PSScriptRoot/../Scripts/Hooks.ps1"; + . "$PSScriptRoot/../Scripts/PowerManagement.ps1"; + . "$PSScriptRoot/../Scripts/SetupConfig.ps1"; + + 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")) { + 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"'; + Restart-Intermediate; + return; + } + + if (Test-Path $env:PWSH_PATH) { + Remove-Item -Recurse $env:PWSH_PATH; + } + }; + } + Default {} + } +} + +function Invoke-WindowsInstallation([Context] $context) { $Global:InformationPreference = "Continue"; $Global:ErrorActionPreference = "Inquire"; $context.UserNames ??= @("Manuel");