POWERSHELL Version 1.0.0
Windows Product Key Retriever
Retrieve full Windows product keys from BIOS/UEFI and the Windows Registry. Displays Windows activation status, license information, and available 25-character product keys. Supports Windows 10 and 11 without additional software.
Source code
SHA-256:704cd84b9d56cd5a1e1ff2840b505d79ebcdc002c2a09a463c90403e5e168767
# ScriptSnatch.com
# Windows Product Key Checker
# Attempts to retrieve the FULL 25-character product key
# No external dependencies
$ErrorActionPreference = "Stop"
function Convert-DigitalProductId {
param([byte[]]$DigitalProductId)
if (-not $DigitalProductId -or $DigitalProductId.Length -lt 67) {
return $null
}
$key = [byte[]]$DigitalProductId[52..66]
$chars = "BCDFGHJKMPQRTVWXY2346789"
$result = ""
$isWin8 = ([math]::Floor($key[14] / 6) -band 1)
$key[14] = [byte](($key[14] -band 0xF7) -bor (($isWin8 -band 2) * 4))
for ($i = 24; $i -ge 0; $i--) {
$current = 0
for ($j = 14; $j -ge 0; $j--) {
$current = ($current * 256) + $key[$j]
$key[$j] = [byte][math]::Floor($current / 24)
$current = $current % 24
}
$result = $chars[$current] + $result
}
if ($isWin8 -eq 1) {
$result = $result.Insert($current, "N")
$result = $result.Substring(1)
}
return ($result -replace '(.{5})(?=.)', '$1-')
}
function Show-Value {
param([string]$Name, [string]$Value)
Write-Host ("{0,-23}: {1}" -f $Name, $Value)
}
Write-Host ""
Write-Host "============================================" -ForegroundColor Cyan
Write-Host " WINDOWS PRODUCT KEY CHECKER" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Write-Host ""
try {
$os = Get-CimInstance Win32_OperatingSystem
$service = Get-CimInstance SoftwareLicensingService
$license = Get-CimInstance SoftwareLicensingProduct |
Where-Object {
$_.Name -like "Windows*" -and
$_.PartialProductKey
} |
Sort-Object @{
Expression = {
if ($_.LicenseStatus -eq 1) { 0 } else { 1 }
}
} |
Select-Object -First 1
Show-Value "Windows" $os.Caption
Show-Value "Version" $os.Version
if ($license) {
$status = if ($license.LicenseStatus -eq 1) {
"Activated"
}
else {
"Not activated (status $($license.LicenseStatus))"
}
Show-Value "Activation" $status
Show-Value "License description" $license.Description
Show-Value "Installed key ending" $license.PartialProductKey
}
Write-Host ""
Write-Host "FULL PRODUCT KEYS" -ForegroundColor Yellow
Write-Host "--------------------------------------------"
# Retrieve OEM key embedded in firmware
$oemKey = $service.OA3xOriginalProductKey
if ($oemKey) {
Show-Value "BIOS/UEFI OEM key" $oemKey
}
else {
Show-Value "BIOS/UEFI OEM key" "Not available"
}
# Read Windows registry product key data
$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
$registry = Get-ItemProperty -LiteralPath $registryPath
# Windows may expose a readable backup key
if ($registry.BackupProductKeyDefault) {
Show-Value "Registry backup key" $registry.BackupProductKeyDefault
}
else {
Show-Value "Registry backup key" "Not available"
}
# Attempt to decode DigitalProductId
if ($registry.DigitalProductId) {
$decodedKey = Convert-DigitalProductId $registry.DigitalProductId
if ($decodedKey) {
Show-Value "Decoded registry key" $decodedKey
}
}
Write-Host ""
Write-Host "NOTE:" -ForegroundColor DarkYellow
Write-Host "Registry keys may be generic installation keys."
Write-Host "They are not necessarily the key used for activation."
Write-Host "A digital license may not have a recoverable full key."
Write-Host ""
}
catch {
Write-Host "ERROR: $($_.Exception.Message)" -ForegroundColor Red
}
Community reviews
No published reviews yet.
Leave a review
Reviews are moderated. Your email is not displayed publicly.