Advertisement
Guest User

11 activation script

a guest
Oct 14th, 2024
11,481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 1 1
  1. #Windows 11 product key
  2. $Key = "PUT-KEY-HERE"
  3.  
  4. # Function to check activation status
  5. function Check-ActivationStatus {
  6. $activationInfo = (Get-WmiObject -Class SoftwareLicensingProduct | Where-Object { $_.PartialProductKey -ne $null -and $_.LicenseFamily -like "*Windows*" })
  7. return $activationInfo | Select-Object -ExpandProperty LicenseStatus
  8. }
  9.  
  10. # Check activation status
  11. $activationStatus = Check-ActivationStatus
  12.  
  13. if ($activationStatus -eq 1) {
  14. Write-Host "Windows is activated. No action needed."
  15. } else {
  16. Write-Host "Windows is not activated. Attempting to install and activate the key..."
  17.  
  18. # Installing Key
  19. try {
  20. slmgr.vbs /ipk $Key
  21. Write-Host "Product key installed successfully."
  22.  
  23. # Activating Windows
  24. slmgr.vbs /ato
  25. Write-Host "Activation attempted."
  26.  
  27. # Check activation status after activating
  28. $activationStatus = Check-ActivationStatus
  29.  
  30. if ($activationStatus -eq 1) {
  31. Write-Host "Windows is now activated."
  32. } else {
  33. Write-Host "Activation failed."
  34. }
  35. } catch {
  36. Write-Host "An error occurred: $_"
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement