Windows 11 Upgrade from Windows 10
Powershell Script
$desktopUserPath = [Environment]::GetFolderPath("Desktop")
$desktopPublicPath = [Environment]::GetFolderPath("CommonDesktopDirectory")
$downloadsPath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile), "Downloads")
$teamviewerPath = [System.IO.Path]::Combine($downloadsPath, "teamviewerqs11.exe")
$teamviewerDesktopPath = [System.IO.Path]::Combine($desktopPublicPath, "FTINC.exe")
$teamviewerUrl = "https://download.teamviewer.com/download/version_11x/TeamViewerQS.exe"
$upgradeUrl = "https://go.microsoft.com/fwlink/?linkid=2171764"
$upgradePath = "$downloadsPath\Win11Upgrade.exe"
# Check if the script is running as an administrator
if (-not ([bool] ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))) {
Write-Host "You need to run this script as an Administrator!"
exit 1
}
Write-Host $downloadsPath
Write-Host $teamviewerDesktopPath
# download common installers
Invoke-WebRequest -Uri $teamviewerUrl -OutFile $teamviewerPath
Copy-Item -Path $teamviewerPath -Destination $teamviewerDesktopPath -Force
# Download the file
try {
Invoke-WebRequest -Uri $upgradeUrl -OutFile $upgradePath
Write-Host "Download completed successfully."
} catch {
Write-Host "Error downloading the file: $_"
exit 1
}
# bypass cpu Check
$registryPath = "HKLM:\System\Setup\LabConfig"
New-Item -Path $RegistryPath -Force | Out-Null
Set-ItemProperty -Path $registryPath -Name "BypassCPUCheck" -Value 1
$registryPath = "HKLM:\System\Setup\MoSetup"
New-Item -Path $RegistryPath -Force | Out-Null
Set-ItemProperty -Path $registryPath -Name "AllowUpgradesWithUnsupportedTPMOrCPU" -Value 1
# Define the start and end times for active hours
$activeHoursStart = 7
$activeHoursEnd = 20
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "ActiveHoursStart" -Value $activeHoursStart
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "ActiveHoursEnd" -Value $activeHoursEnd
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "UserChoiceActiveHoursStart" -Value $activeHoursStart
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "UserChoiceActiveHoursEnd" -Value $activeHoursEnd
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "SmartActiveHoursState" -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "AllowMUUpdateService" -Value 1
# check for free hdd space
$thresholdGB = 60
$systemDrive = Get-PSDrive -Name $env:SystemDrive.Substring(0, 1)
$freeSpaceGB = [math]::Round($systemDrive.Free / 1GB, 2)
if ($freeSpaceGB -lt $thresholdGB) {
Write-Warning "Low disk space: $($freeSpaceGB) GB"
exit 1
}
# Start the upgrade process
try {
Start-Process -FilePath $upgradePath -ArgumentList "/Install /MinimizeToTaskBar /QuietInstall /SkipEULA"
Write-Host "Upgrade process started."
} catch {
Write-Host "Error starting the upgrade process: $_"
exit 1
}