Get (Calculate) Windows Product Key using PowerShell

There are some tools in the web that can read out Product Keys from a running Windows installation. There’s also a cool guy that wrote a PowerShell Script that can do the same. Christian Haberl published his Script on his blog here:

http://blog.this.at/post/2010/03/06/Windows-Product-Key-per-Powershell-auslesen.aspx

Source Code:

function Get-ProductKey {

$map=“BCDFGHJKMPQRTVWXY2346789”
$value = (get-itemproperty “HKLM:\\SOFTWARE\Microsoft\Windows NT\CurrentVersion”
).digitalproductid[0x34..0x42]
$ProductKey = “”
for ($i = 24; $i -ge 0; $i–
) {
$r =
0
for ($j = 14; $j -ge 0; $j–
) {
$r = ($r * 256) -bxor $value[$j
]
$value[$j] = [math]::Floor([double]($r/
24))
$r = $r %
24
  }
$ProductKey = $map[$r] +
$ProductKey
if (($i % 5) -eq 0 -and $i -ne
0) {
$ProductKey = “-” +
$ProductKey
  }
}
echo “Product Key:” $ProductKey

}

Very cool! Thanks Christian for publishing that code.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s