# Check for existing product key $key = (Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey if ($key) { Write-Host "Product Key Found: $key" } else { Write-Host "No embedded product key found." $key = Read-Host "Please enter a valid Windows product key to continue" } # Confirm upgrade $confirm = Read-Host "Do you want to upgrade Windows using this key? (Y/N)" if ($confirm -eq "Y") { try { # Initiate upgrade Write-Host "Attempting to upgrade Windows..." slmgr.vbs /ipk $key slmgr.vbs /ato Write-Host "Upgrade initiated. Please restart your PC if prompted." } catch { Write-Host "Upgrade failed. Please check the key and try again." } } else { Write-Host "Upgrade canceled by user." }