From b034dfd53d4e8cd571d934525bc8c2ecde6ca704 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 9 Aug 2024 16:02:24 +0200 Subject: [PATCH] Install updates only as admin --- scripts/Windows/OS/Install.ps1 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index ca9a59dd..3bcf86c8 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -124,15 +124,17 @@ $null = New-Module { break; } default { - $null = Import-Module PSWindowsUpdate; + if (Test-Admin) { + $null = Import-Module PSWindowsUpdate; - Invoke-Hook "Invoke-WindowsUpdate" -Fallback { - Update-WindowsInstallation; - }; + Invoke-Hook "Invoke-WindowsUpdate" -Fallback { + Update-WindowsInstallation; + }; - if ((Get-WURebootStatus -Silent)) { - Restart-Intermediate; - return; + if ((Get-WURebootStatus -Silent)) { + Restart-Intermediate; + return; + } } <#