-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWin11_Activate.ps1
More file actions
69 lines (55 loc) · 2.45 KB
/
Win11_Activate.ps1
File metadata and controls
69 lines (55 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Win11_Activate.ps1
# ---------------------------------------------
# PowerShell script to activate Windows 11
# - Shows system info
# - Shows current license/activation status
# - Prompts for product key
# - Applies key and activates Windows
# ---------------------------------------------
# Check if running as admin
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "This script requires administrator privileges." -ForegroundColor Yellow
Write-Host "Restarting with elevated permissions..." -ForegroundColor Yellow
# Restart the script with admin privileges
$scriptPath = $MyInvocation.MyCommand.Path
Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`"" -Verb RunAs
exit
}
Write-Host "=== Windows 11 Activation Utility ===" -ForegroundColor Cyan
Write-Host ""
# Show basic system info
Write-Host "Gathering system information..." -ForegroundColor Yellow
$sys = Get-ComputerInfo
Write-Host "Computer Name: $($sys.CsName)"
Write-Host "OS Name: $($sys.OsName)"
Write-Host "OS Version: $($sys.OsVersion)"
Write-Host "Build Number: $($sys.OsBuildNumber)"
Write-Host ""
# Show activation / license status
Write-Host "Retrieving current activation status..." -ForegroundColor Yellow
# Use slmgr to display licensing info
Write-Host ""
Write-Host "Current License Information:" -ForegroundColor Cyan
cscript /nologo "$env:SystemRoot\System32\slmgr.vbs" /dlv
Write-Host ""
# Prompt for product key
Write-Host ""
$productKey = Read-Host -Prompt "Enter your 25-character Windows product key (format: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX)"
if ($productKey -notmatch '^[A-Z0-9]{5}(-[A-Z0-9]{5}){4}$') {
Write-Host "ERROR: Invalid product key format." -ForegroundColor Red
exit 1
}
Write-Host "Installing product key..." -ForegroundColor Yellow
cscript /nologo "$env:SystemRoot\System32\slmgr.vbs" /ipk $productKey
# Activate Windows
Write-Host "Activating Windows..." -ForegroundColor Yellow
cscript /nologo "$env:SystemRoot\System32\slmgr.vbs" /ato
Write-Host ""
Write-Host "Activation attempt complete." -ForegroundColor Green
Write-Host ""
# Display updated activation info
Write-Host "Updated License Information:" -ForegroundColor Cyan
cscript /nologo "$env:SystemRoot\System32\slmgr.vbs" /dli
pause