From b8c6038da88ff52bca2ebd388fcef21d000748bc 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 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index 59d2a5d8..658d0884 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -123,15 +123,17 @@ $null = New-Module { break; } default { - $null = Import-Module PSWindowsUpdate; - - Invoke-Hook "Invoke-WindowsUpdate" -Fallback { - Update-WindowsInstallation; - }; - - if ((Get-WURebootStatus -Silent)) { - Restart-Intermediate; - return; + if (Test-Admin) { + $null = Import-Module PSWindowsUpdate; + + Invoke-Hook "Invoke-WindowsUpdate" -Fallback { + Update-WindowsInstallation; + }; + + if ((Get-WURebootStatus -Silent)) { + Restart-Intermediate; + return; + } } <#