Last active
October 10, 2020 02:44
-
-
Save jonathanelbailey/78817a36121b231f94b5 to your computer and use it in GitHub Desktop.
A Function that utilizes oa3tool.exe to activate Windows 8/8.1 32/64-bit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Set-UEFIActivation{ | |
<# | |
.NAME | |
Set-UEFIActivation | |
.AUTHOR | |
Jonathan Bailey | |
.SYNOPSIS | |
Pulls the Product key hex value from the motherboard, converts it to ASCII, and pipes it to slmgr.vbs for activation. | |
.SYNTAX | |
Set-UEFIActivation [-OA3ToolPath] <string> | |
.DESCRIPTION | |
This script pulls the product key from a UEFI/Windows 8 motherboard for use in oem key activation in legacy mode. | |
Make sure to Have oa3tool.exe in the same working directory as this script. It is part of Microsoft ADK. | |
Use this script to install 32-bit versions of Windows 8.1 on UEFI OEM machines running in legacy mode. | |
Since activation doesn't occur automatically, manual activation is necessary. Find Microsoft ADK here: | |
http://www.microsoft.com/en-us/download/details.aspx?id=39982 | |
#> | |
[CmdletBinding(DefaultParameterSetName="OA3ToolPath", | |
SupportsShouldProcess=$true, | |
PositionalBinding=$true | |
)] | |
Param( | |
[Parameter(Mandatory=$true, | |
ValueFromPipelineByPropertyName=$true, | |
Position=0)] | |
$OA3ToolPath | |
) | |
BEGIN{} | |
PROCESS{ | |
# pull the hex value from motherboard and outputs it to $hexdata | |
Start-Process -FilePath $OA3ToolPath -ArgumentList '/validate' -RedirectStandardOutput .\validate.txt | |
$HexData = Get-Content .\validate.txt | |
# Find the hex value that contains the product key and formats/trims it for conversion. | |
$HexData = $HexData | select -First 33 | select -Last 4 | |
$HexData = $HexData -replace '\s+', ' ' | |
$HexData = $HexData.trimstart(' ') | |
$HexData = $HexData.trimend(' ') | |
# Split hex values into objects and convert them to decimal, then decimal to ASCII, | |
# then set the new value as $prodkey. | |
$HexData.split(" ") | FOREACH {[CHAR][BYTE]([CONVERT]::toint16($_,16))} | Set-Variable -name prodkey -PassThru | |
# join the ascii array into a string | |
$prodkey = $prodkey -join '' | |
# regex replace all unprintable characters. | |
$prodkey = $prodkey -replace "[^ -x7e]","" | |
write-host | |
write-host success! | |
# use slmgr.vbs for activation. | |
cscript //b slmgr.vbs /ipk $prodkey | |
} | |
END{ | |
Remove-Item .\validate.txt | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment