CMD Win 11 Upgrade (Block‐Force) - Neilitlib/MSP-Simple-Commands GitHub Wiki

BLOCKED

  • Should be run on a Windows 10 PC to prevent accidental upgrade to Windows 11
  • Less likely to be an issue in most environments unless the user has local admin rights
  • CAUTION, if run on a Windows 11 PC, it will set the Target Release Version to Windows 11 22H2

CLI

  • reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v TargetReleaseversion /t REG_DWORD /d 1
  • reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v TargetReleaseversionInfo /t REG_SZ /d 22H2

These commands are used to add entries to the Windows Registry, specifically to control the behavior of Windows Update. Here's a breakdown of each command:

  1. reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v TargetReleaseversion /t REG_DWORD /d 1: This command adds a DWORD value named TargetReleaseversion to the HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate registry key and sets its data to 1. This tells Windows Update to target a specific version of Windows.
  2. reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v TargetReleaseversionInfo /t REG_SZ /d 22H2: This command adds a string value named TargetReleaseversionInfo to the same registry key and sets its data to 22H2. This specifies the target version of Windows to be 22H2.

In summary, these commands configure Windows Update to target the 22H2 version of Windows 10. Please note that modifying the Windows Registry can have significant effects on your system, so it should be done with caution. Always ensure you have a backup of your important data and system state before making changes to the registry. Also, these commands need to be run with administrative privileges.

FORCED & SILENT

  • The next time the user reboots their PC, they will have Windows 11
  • Useful for Windows 10 End-Of-Life upgrades
  • CAUTION, may break some software that is not compatible with Windows 11
  • In summary, this script downloads the Windows 11 Installation Assistant and starts it with specific arguments to automatically upgrade the system to Windows 11. The installation logs are saved to C:\temp\Win11. Please note that running scripts like this should be done with caution, as they can make significant changes to your system. Always ensure you have a backup of your important data.

- Deletes Potential "Block Upgrade" Registry Entries

CLI

  • reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v TargetReleaseversionInfo /f

  • reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v TargetReleaseversion /f

Entries may not be present but would have been manually pushed out as they are not part of the default Windows 10 operating system

- Silently Upgrade Windows 10 to Windows 11

PS

  1. Set-ExecutionPolicy Bypass -Force -Confirm:$false; Install-PackageProvider -Name NuGet -Force -Confirm:$false; Install-Module PSWindowsUpdate -Force -Confirm:$false

  2. Import-Module PSWindowsUpdate; $dir = 'C:\temp\Win11'; try { if (-Not (Test-Path -Path $dir)) { New-Item -ItemType Directory -Path $dir -ErrorAction Stop } } catch { Write-Error "Failed to create directory: $_"; exit 1 }; $webClient = New-Object System.Net.WebClient; $url = 'https://go.microsoft.com/fwlink/?linkid=2171764'; $file = "$($dir)\Windows11InstallationAssistant.exe"; try { $webClient.DownloadFile($url, $file) } catch { Write-Error "Failed to download file: $_"; exit 1 }; try { Start-Process -FilePath $file -ArgumentList "/quietinstall /skipeula /autoupgrade /NoRestartUI /copylogs $dir" -Verb RunAs -ErrorAction Stop } catch { Write-Error "Failed to start process: $_"; exit 1 }


This PowerShell script performs the following actions: Sure! Here's a simple breakdown of what the script does:

  1. Import the Module: 'Import-Module PSWindowsUpdate' - Loads the PSWindowsUpdate module to manage Windows updates.

  2. Set Directory Path: '$dir = 'C:\temp\Win11'' - Defines the path where the downloaded file will be saved.

  3. Create Directory:

    • 'try { if (-Not (Test-Path -Path $dir)) { New-Item -ItemType Directory -Path $dir -ErrorAction Stop } } catch { Write-Error "Failed to create directory: $_"; exit 1 }' - Checks if the directory exists. If not, it creates the directory and handles any errors.
  4. Create Web Client: '$webClient = New-Object System.Net.WebClient' - Creates a web client to download files from the internet.

  5. Set Download URL: '$url = 'https://go.microsoft.com/fwlink/?linkid=2171764'' - Specifies the URL of the file to be downloaded.

  6. Set File Path: '$file = "$($dir)\Windows11InstallationAssistant.exe"' - Defines the path and name for the downloaded file.

  7. Download File:

    • 'try { $webClient.DownloadFile($url, $file) } catch { Write-Error "Failed to download file: $_"; exit 1 }' - Downloads the file from the URL and handles any errors.
  8. Run Installer:

    • 'try { Start-Process -FilePath $file -ArgumentList "/quietinstall /skipeula /autoupgrade /NoRestartUI /copylogs $dir" -Verb RunAs -ErrorAction Stop } catch { Write-Error "Failed to start process: $_"; exit 1 }' - Runs the downloaded installer with administrative privileges and specified arguments, handling any errors.

This script automates the process of downloading and starting the Windows 11 Installation Assistant, ensuring it runs with the necessary permissions and handles any issues that might arise.