How to Enable Automatic Windows 11 Upgrade Using a Custom PowerShell Script

With the advent of Windows 11, enabling its upgrade became a primary focus for IT professionals. Understanding and managing operating system transitions is crucial in the IT sector, especially as businesses work to remain compatible with the latest technologies. The script in focus offers a streamlined way to pave the way for the Windows 11 upgrade.

Background

The script’s purpose is straightforward: it enables the upgrade to Windows 11. Specifically tailored for the Windows 10 OS architecture, its primary aim is to trigger the upgrade offer for Windows 11 to users. This is pivotal for IT professionals and Managed Service Providers (MSPs) to ensure that end-users receive timely upgrades without hitches. By maintaining system compatibility and leveraging the latest features, businesses can guarantee optimal performance and security.

The Script


<#
.SYNOPSIS
    Enables Windows 11 upgrade.
.DESCRIPTION
    Enables Windows 11 upgrade.
.EXAMPLE
    No parameters needed
    Enables Windows 11 upgrade.
.OUTPUTS
    None
.NOTES
    Minimum OS Architecture Supported: Windows 10
    Release Notes:
    Allows the upgrade offer to Windows 11 to appear to users
    (c) 2023 NinjaOne
    By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https://www.ninjaone.com/terms-of-use.
    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. 
    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. 
    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. 
    Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. 
    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. 
    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. 
    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).
#>
[CmdletBinding()]
param ()

begin {
    function Test-IsElevated {
        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
        $p = New-Object System.Security.Principal.WindowsPrincipal($id)
        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
    }
}
process {
    if (-not (Test-IsElevated)) {
        Write-Error -Message "Access Denied. Please run with Administrator privileges."
        exit 1
    }

    $Splat = @{
        Path        = "HKLM:SOFTWAREPoliciesMicrosoftWindowsWindowsUpdate"
        Name        = @("TargetReleaseVersion", "TargetReleaseVersionInfo")
        ErrorAction = "SilentlyContinue"
    }

    Remove-ItemProperty @Splat -Force
    Remove-ItemProperty -Path "HKLM:SOFTWAREMicrosoftWindowsUpdateUXSettings" -Name "SvOfferDeclined" -Force -ErrorAction SilentlyContinue
    $TargetResult = Get-ItemProperty @Splat
    $OfferResult = Get-ItemProperty -Path "HKLM:SOFTWAREMicrosoftWindowsUpdateUXSettings" -Name "SvOfferDeclined" -ErrorAction SilentlyContinue
    if ($null -ne $TargetResult -or $null -ne $OfferResult) {
        Write-Host "Failed to enable Windows 11 Upgrade."
        exit 1
    }
    exit 0
}
end {}

 

Access 300+ scripts in the NinjaOne Dojo

Get Access

Script Detailed Breakdown

Preparation Phase

The script starts with a CmdletBinding attribute, commonly used for advanced functions in PowerShell. It doesn’t require any parameters.

The script then checks if the user running the script has administrative rights with the Test-IsElevated function.

Execution Phase

If the user doesn’t have administrative rights, an error message is thrown.

The script defines a variable $Splat which holds information related to the Windows Update registry path and some properties.

It then attempts to remove certain registry properties related to the Windows update using the Remove-ItemProperty command, effectively clearing potential blocks or specific target versions that may prevent the upgrade.

Finally, the script checks whether these registry properties were successfully removed. If they were not, it signals a failure in enabling the upgrade.

Completion Phase

The script exits with a status code. A zero (0) indicates successful completion, while one (1) signifies an error.

Potential Use Cases

Imagine an IT professional, George, working for a medium-sized enterprise. The company decides to transition to Windows 11 to leverage its new features. George, tasked with ensuring a smooth transition, utilizes this script to batch-enable the upgrade across all systems, saving significant manual work.

Alternative Approach

Traditional methods of enabling Windows 11 upgrades might involve manual changes in system settings or using GUI-based tools which are time-consuming and prone to errors. This script automates the process, making it more efficient and error-resistant.

FAQs

  1. Will this script work for OS other than Windows 10?
    The script is primarily designed for Windows 10, as highlighted in the notes.
  2. What if the script doesn’t work?
    It’s essential to run the script with administrative rights. If faced with issues, re-running it or consulting with IT specialists is advisable.

Implications

While the script offers a way to enable the Windows 11 upgrade seamlessly, any automated process comes with risks. Altering registry settings can have unintended consequences. IT professionals must ensure they have backup strategies in place, test the script in controlled environments, and always prioritize IT security.

Recommendations

  • Always backup critical data and system settings before running scripts.
  • Test the script on a small sample of machines before broad deployment.
  • Ensure users are informed about upgrades to prevent surprises.

Final Thoughts

Transitioning to new OS versions can be daunting. Using tools and scripts like the one discussed can ease the process. Furthermore, an IT management platform like NinjaOne can further assist in managing such transitions, offering monitoring and automation capabilities that are invaluable in today’s rapidly evolving IT landscape.

Add a Comment

Your email address will not be published. Required fields are marked *

Next Steps

Building an efficient and effective IT team requires a centralized solution that acts as your core service deliver tool. NinjaOne enables IT teams to monitor, manage, secure, and support all their devices, wherever they are, without the need for complex on-premises infrastructure.

Learn more about NinjaOne Remote Script Deployment, check out a live tour, or start your free trial of the NinjaOne platform.

Categories:

You might also like

Watch Demo×
×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).