From cf7c776e5596dd63160f7b0c9bf336801e596fe8 Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Tue, 6 Aug 2024 18:19:33 +0200
Subject: [PATCH] Install PowerShell modules after removing old copy

---
 scripts/Windows/OS/Install.ps1 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1
index 24eb2a7a..38333fab 100644
--- a/scripts/Windows/OS/Install.ps1
+++ b/scripts/Windows/OS/Install.ps1
@@ -55,16 +55,16 @@ $null = New-Module {
                     return;
                 }
 
-                Invoke-Hook "Install-PSModules" -Fallback {
-                    Install-Module -AcceptLicense -Force PSWindowsUpdate;
-                };
-
                 if (Test-Path $env:PWSH_PATH) {
                     attrib "-R" "$env:PWSH_PATH\*" /S /D;
                     Remove-Item -Recurse -Force $env:PWSH_PATH;
                     continue;
                 }
 
+                Invoke-Hook "Install-PSModules" -Fallback {
+                    Install-Module -AcceptLicense -Force PSWindowsUpdate;
+                };
+
                 if (-not (Test-Command winget)) {
                     . "$PSScriptRoot/../Software/winget/Manage.ps1";
                     continue;