A breathtaking view of a snow-capped mountain range under a clear sky, capturing winter's beauty.

Upgrading Windows Editions with PowerShell and a MAK Key

Introduction

This PowerShell script facilitates the upgrade of Windows 11 Education to the Enterprise edition using a Multiple Activation Key (MAK). It automates the process of installing the MAK product key, activating Windows, and verifying the activation status.

Use Case

This script is valuable for:

  • Automating Upgrades: Simplifying the upgrade process for Windows 11 Education to Enterprise, reducing manual intervention.
  • Large-Scale Deployments: Enabling efficient upgrades across a large number of devices.
  • Centralized Management: Allowing administrators to manage Windows edition upgrades from a central location.

Script

PowerShell

# ---------------------------------------------
# Script: Upgrade-WindowsEdition.ps1
# Purpose: Upgrade Windows 11 Education to Enterprise using a MAK key
# ---------------------------------------------

# Define the Windows 11 Enterprise MAK product key
$enterpriseProductKey = "<Your MAK Key>" 

# Function to log messages
function Write-Log {
    param (
        [string]$Message
    )
    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    $logPath = "C:\Windows\Temp\Upgrade-WindowsEdition.log"
    # Ensure the log directory exists
    if (-not (Test-Path -Path "C:\Windows\Temp")) {
        New-Item -Path "C:\Windows\Temp" -ItemType Directory -Force
    }
    Add-Content -Path $logPath -Value "$timestamp - $Message"
}

# Start the upgrade process
try {
    Write-Log "Starting Windows 11 Education to Enterprise upgrade using MAK key."

    # Install the Enterprise MAK product key
    Write-Log "Installing the Enterprise MAK product key."
    cscript C:\windows\system32\slmgr.vbs /ipk $enterpriseProductKey | Out-Null 

    # Activate Windows with the new MAK key
    Write-Log "Activating Windows with the Enterprise MAK product key."
    cscript C:\windows\system32\slmgr.vbs /ato | Out-Null 

    # Verify activation status
    Write-Log "Verifying activation status."
    $activationStatus = (Get-CimInstance -ClassName SoftwareLicensingProduct -Filter "LicenseStatus=1 AND PartialProductKey <> null").LicenseStatus 

    if ($activationStatus -eq 1) {
        Write-Log "Windows activated successfully with the Enterprise edition."
    } else {
        Write-Log "Windows activation failed. Please check the MAK product key and network connectivity."
        exit 1
    }

    # Restart the computer to apply changes
    Write-Log "Restarting the computer to apply changes."
    Restart-Computer -Force 
}
catch {
    Write-Log "An error occurred: $_"
    exit 1
}

Explanation

  • MAK Key: The script defines a variable to store the Windows 11 Enterprise MAK product key.
  • Logging Function: It includes a function Write-Log to record messages with timestamps in a log file.
  • Install Product Key: The script uses slmgr.vbs /ipk to install the MAK product key.
  • Activate Windows: It then uses slmgr.vbs /ato to activate Windows with the new key.
  • Verify Activation: The script checks the activation status using Get-CimInstance to ensure the upgrade was successful.
  • Restart Computer: Finally, it restarts the computer to apply the changes.
  • Error Handling: The script uses a try-catch block to handle potential errors during the upgrade process.

Outro

This script provides a streamlined method for upgrading Windows 11 Education to Enterprise using a MAK key. It can be integrated with other deployment tools or used independently to automate the upgrade process.

Tags

PowerShell, Windows 11, Upgrade, Education, Enterprise, MAK Key, Activation, Automation, Scripting, slmgr.vbs

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

WordPress Cookie Plugin by Real Cookie Banner