From b49fc2f9aadf3b1603b10cee03ce0307f3059cf5 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 27 Aug 2024 00:45:46 +0200 Subject: [PATCH] Streamline PowerShell installation --- scripts/Windows/OS/Install.ps1 | 36 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index 796665f2..ed7d8c36 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -160,25 +160,39 @@ $null = New-Module { wsl --shutdown; continue; } + + Invoke-Hook "Install-PSModules" -Fallback { + $modules = @( + @("KnownFolders"), + @("PSWindowsUpdate"), + @("PSScriptAnalyzer"), + @("LocalAccounts", $true), + @("NuGet") + ); + + foreach ($module in $modules) { + $parameters = @{ }; + + if ($module[1]) { + $parameters = @{ + allowPrerelease = $true; + }; + } + + Install-Module -Scope AllUsers -AcceptLicense -Force $module[0] @parameters; + Import-Module $module[0]; + } + + . "$PSScriptRoot/../Software/PinnedItem/Manage.ps1"; + }; if (-not (Test-PSPackage Selenium.WebDriver)) { Write-Host "Installing browser automation tools…"; - Install-Module -AcceptLicense -Force NuGet; - Import-Module NuGet; $null = Install-Package -Force Selenium.WebDriver -RequiredVersion 4.10.0 -SkipDependencies; continue; } Install-ChocoPackage selenium-gecko-driver firefox; - - Invoke-Hook "Install-PSModules" -Fallback { - Install-Module -Scope AllUsers -AcceptLicense -Force KnownFolders; - Install-Module -Scope AllUsers -AcceptLicense -Force PSWindowsUpdate; - Install-Module -Scope AllUsers -AcceptLicense -Force PSScriptAnalyzer; - Install-Module -Scope AllUsers -AcceptLicense -AllowPrerelease -AllowClobber -Force LocalAccounts; - Import-Module LocalAccounts; - . "$PSScriptRoot/../Software/PinnedItem/Manage.ps1"; - }; Install-WingetPackage AutoHotkey.AutoHotkey; Set-Stage ([SetupStage]::Configure);