Skip to content

Instantly share code, notes, and snippets.

@warfighter8
Last active June 7, 2018 18:02
Show Gist options
  • Save warfighter8/7d39d66754e46c39beeaf2de4b1c6775 to your computer and use it in GitHub Desktop.
Save warfighter8/7d39d66754e46c39beeaf2de4b1c6775 to your computer and use it in GitHub Desktop.
Script to activate a Windows 10 PC using the OEM key embedded in UEFI
#Script to activate the PC using the OEM key embedded in the Bios
#Author: Terry Wensel
#Last Updated: 6/7/2018
#Uncomment the following part to check for administrator privileges
#param([switch]$Elevated)
#
#Function Test-Admin {
# $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
# $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
#}
#
#if ((Test-Admin) -eq $false) {
# if ($elevated)
# {
# # tried to elevate, did not work, aborting
# }
# else {
# Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
#}
#
#exit
#}
#
#'running with full privileges'
$key = (Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey
iex "cscript /b C:\Windows\System32\slmgr.vbs -ipk $key"
iex "cscript /b C:\Windows\System32\slmgr.vbs -ato"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment