Last active
June 10, 2023 18:19
-
-
Save NielsS79/4b76082ea0eda0264bfbd0f435c0306f to your computer and use it in GitHub Desktop.
Gets the product key stored in UEFI/BIOS and import it.
This file contains 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
<# | |
.SYNOPSIS | |
Reads the Windows (OEM) product key from firmware (UEFI/BIOS), then imports it via slmgr. | |
.NOTES | |
"There are many like it, but this one is mine." | |
Author: Niels Scheffers <niels.scheffers@etesian.nl> | |
Last modified: 2022-03-10 | |
#> | |
Try { | |
# Get OEM product key from firmware. | |
$oemProductKey = (Get-WmiObject -Query 'SELECT * FROM SoftwareLicensingService').OA3xOriginalProductKey; | |
# Import the key. | |
Invoke-Command -ScriptBlock { slmgr -ipk $oemProductKey; } | |
} | |
Catch { | |
Throw "Failed to set Windows product key."; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment