From 8cf16b5c899a60ea5982c5d8dc042153daf6ac5b Mon Sep 17 00:00:00 2001 From: heqnx Date: Fri, 11 Jul 2025 21:50:55 +0300 Subject: added packer templates --- packer/files/scripts/windows/disable-updates.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 packer/files/scripts/windows/disable-updates.ps1 (limited to 'packer/files/scripts/windows/disable-updates.ps1') diff --git a/packer/files/scripts/windows/disable-updates.ps1 b/packer/files/scripts/windows/disable-updates.ps1 new file mode 100644 index 0000000..69d6441 --- /dev/null +++ b/packer/files/scripts/windows/disable-updates.ps1 @@ -0,0 +1,13 @@ +# https://learn.microsoft.com/en-us/windows/win32/api/wuapi/ne-wuapi-automaticupdatesnotificationlevel +# https://learn.microsoft.com/en-us/archive/blogs/jamesone/managing-windows-update-with-powershell +try { + $updates = (New-Object -ComObject "Microsoft.Update.AutoUpdate").Settings + if ($updates.ReadOnly -eq $true) { + Write-Error "[ERR] Cannot update Windows Update settings due to GPO restrictions" + } else { + $updates.NotificationLevel = 1 + $updates.Save() + $updates.Refresh() + Write-Output "[INFO] Automatic Windows Updates disabled" + } +} catch { Write-Output "[ERR] Exception while disabling Automatic Windows Updates" } -- cgit v1.2.3