From ea83940e395caf39c421e3c97e979aa78a33f57c 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 9a3c63d6..92ec326d 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -164,25 +164,39 @@ $null = New-Module { 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); break;