Idera nSoftware Compellent

Retrieve Product Key of Windows


posted by Sylvain LESIRE
02-18-2009

Downloads: 681
File size: 736 B
Views: 3,312

Embed
Retrieve Product Key of Windows
  1. # create table to convert in base 24 
  2. $map="BCDFGHJKMPQRTVWXY2346789" 
  3. # Read registry Key 
  4. $value = (get-itemproperty "HKLM:\\SOFTWARE\Microsoft\Windows NT\CurrentVersion").digitalproductid[0x34..0x42] 
  5. # Convert in Hexa to show you the Raw Key 
  6. $hexa = "" 
  7. $value | foreach
  8.   $hexa = $_.ToString("X2") + $hexa 
  9. "Raw Key Big Endian: $hexa" 
  10.  
  11. # find the Product Key 
  12. $ProductKey = "" 
  13. for ($i = 24; $i -ge 0; $i--) { 
  14.   $r =
  15.   for ($j = 14; $j -ge 0; $j--) { 
  16.     $r = ($r * 256) -bxor $value[$j
  17.     $value[$j] = [math]::Floor([double]($r/24)) 
  18.     $r = $r % 24 
  19.   
  20.   $ProductKey = $map[$r] + $ProductKey  
  21.   if (($i % 5) -eq 0 -and $i -ne 0) { 
  22.     $ProductKey = "-" + $ProductKey 
  23.   
  24. "Product Key: $ProductKey" 

This script was found on

http://www.powershell-scripting.com (french powershell community)

Thanks to Janel , Arnaud Le petit, Jean Claude Bellamy

Copyright 2010 PowerShell.com. All rights reserved.