diff options
author | heqnx <root@heqnx.com> | 2025-07-11 21:50:55 +0300 |
---|---|---|
committer | heqnx <root@heqnx.com> | 2025-07-11 21:50:55 +0300 |
commit | 8cf16b5c899a60ea5982c5d8dc042153daf6ac5b (patch) | |
tree | d64092854fe32f4630f514b93b244b0b5eddc5d1 /packer/files/scripts/windows/disable-updates.ps1 | |
parent | 54ecdd04947e70026c96365ea29463f8b435c1aa (diff) | |
download | ansible-active-directory-range-8cf16b5c899a60ea5982c5d8dc042153daf6ac5b.tar.gz ansible-active-directory-range-8cf16b5c899a60ea5982c5d8dc042153daf6ac5b.zip |
added packer templates
Diffstat (limited to 'packer/files/scripts/windows/disable-updates.ps1')
-rw-r--r-- | packer/files/scripts/windows/disable-updates.ps1 | 13 |
1 files changed, 13 insertions, 0 deletions
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" } |