Decline Windows 11 upgrade

So it looks like the jerks at Microsoft aren’t offering 21H2 if the machine is Windows 11 capable. You have to go into WU and click ‘Stay on Windows 10 for now’ and then it finds 21H2.

This seems to work to decline (actual value seems to vary but just using 1 seems to be fine). Also gets rid of the tray icon prompt (probably will need to reboot or check for Windows Updates for registry change to be noticed).

reg add HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /f /v SvOfferDeclined /t REG_QWORD /d 1

Other items that may help prevent unintended upgrades:

reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v DisableOSUpgrade /t REG_DWORD /d 1
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v ProductVersion /t REG_DWORD /d 10
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade /f /v AllowOSUpgrade /t REG_DWORD /d 0
reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsStore /f /v DisableOSUpgrade /t REG_DWORD /d 1
reg add HKLM\SYSTEM\Setup\UpgradeNotification /f /v UpgradeAvailable /t REG_DWORD /d 0
# Uninstall Windows PC Health Check
Start-Process -FilePath msiexec.exe -ArgumentList "/x {B1E7D0FD-7CFE-4E0C-A5DA-0F676499DB91} /qn" -Wait
# Prevent Windows PC Health Check install
reg add HKLM\SOFTWARE\Microsoft\PCHC /f /v PreviousUninstall /t REG_DWORD /d 1

Thanks @isaacg. Here is a script cobbled together with block and unblock options. This should make it easy to schedule with defaults and for the techs to run manually if they need to unblock. I like to have Install and Uninstall in the same scripts now that my list of scripts is getting long.

Import-Module $env:SyncroModule
## Add Syncro dropdown variable "mode" with "block" (default) and "unblock" options
## Add Syncro dropdown variable "TargetVersion" with "21H1", "21H2", etc. options

if ($mode -eq "block"){
    reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v TargetReleaseVersion /t REG_DWORD /d 1
    reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v TargetReleaseVersionInfo /t REG_SZ /d $TargetVersion
    
    reg add HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /f /v SvOfferDeclined /t REG_QWORD /d 1

    reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v DisableOSUpgrade /t REG_DWORD /d 1
    reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v ProductVersion /t REG_DWORD /d 10
    reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade /f /v AllowOSUpgrade /t REG_DWORD /d 0
    reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsStore /f /v DisableOSUpgrade /t REG_DWORD /d 1
    reg add HKLM\SYSTEM\Setup\UpgradeNotification /f /v UpgradeAvailable /t REG_DWORD /d 0
    # Uninstall Windows PC Health Check
    Start-Process -FilePath msiexec.exe -ArgumentList "/x {B1E7D0FD-7CFE-4E0C-A5DA-0F676499DB91} /qn" -Wait
    # Prevent Windows PC Health Check install
    reg add HKLM\SOFTWARE\Microsoft\PCHC /f /v PreviousUninstall /t REG_DWORD /d 1
    
}

if ($mode -eq "unblock") {
    # Undo Set Windows to not upgrade past 21H2 (prevent Windows 11 auto-upgrade)
    reg delete HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v TargetReleaseVersion
    reg delete HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v TargetReleaseVersionInfo
    # Undo Other possible prevention
    reg delete HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v DisableOSUpgrade
    reg delete HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v ProductVersion
    reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade /f /v AllowOSUpgrade
    reg delete HKLM\SOFTWARE\Policies\Microsoft\WindowsStore /f /v DisableOSUpgrade
    reg delete HKLM\SYSTEM\Setup\UpgradeNotification /f /v UpgradeAvailable
    # Undo Prevent Windows PC Health Check install
    reg delete HKLM\SOFTWARE\Microsoft\PCHC /f /v PreviousUninstall
}