When we activate our Windows OS with activation key, the information is stored in the Windows Registry. Here’s a situation to be avoided. For one reason or the other you have to reinstall the Windows operating system but you discover that you don’t know the product key.
Worries Don't worries Use this script to extract your product key from the OS installed on your PC without using any third party software.
- Open Notepad
- Copy and paste the following text into the notepad window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | function Get-WindowsKey { ## function to retrieve the Windows Product Key from any PC ## by Nedim Mehic param ($targets = "." ) $hklm = 2147483650 $regPath = "Software\Microsoft\Windows NT\CurrentVersion" $regValue = "DigitalProductId" Foreach ($target in $targets) { $productKey = $null $win 32 os = $null $wmi = [WMIClass] "\\$target\root\default:stdRegProv" $data = $wmi.GetBinaryValue($hklm,$regPath,$regValue) $binArray = ($data.uValue)[ 52 .. 66 ] $charsArray = "B" , "C" , "D" , "F" , "G" , "H" , "J" , "K" , "M" , "P" , "Q" , "R" , "T" , "V" , "W" , "X" , "Y" , "2" , "3" , "4" , "6" , "7" , "8" , "9" ## decrypt base 24 encoded binary data For ($i = 24 ; $i -ge 0 ; $i--) { $k = 0 For ($j = 14 ; $j -ge 0 ; $j--) { $k = $k * 256 -bxor $binArray[$j] $binArray[$j] = [math]::truncate($k / 24 ) $k = $k % 24 } $productKey = $charsArray[$k] + $productKey If (($i % 5 -eq 0 ) -and ($i -ne 0 )) { $productKey = "-" + $productKey } } $win 32 os = Get-WmiObject Win 32 _OperatingSystem -computer $target $obj = New-Object Object $obj | Add-Member Noteproperty Computer -value $target $obj | Add-Member Noteproperty Caption -value $win 32 os.Caption $obj | Add-Member Noteproperty CSDVersion -value $win 32 os.CSDVersion $obj | Add-Member Noteproperty OSArch -value $win 32 os.OSArchitecture $obj | Add-Member Noteproperty BuildNumber -value $win 32 os.BuildNumber $obj | Add-Member Noteproperty RegisteredTo -value $win 32 os.RegisteredUser $obj | Add-Member Noteproperty ProductID -value $win 32 os.SerialNumber $obj | Add-Member Noteproperty ProductKey -value $productkey $obj } } |
- Save the file with the .ps1 extension on the Desktop or C:\. Exemple ProductKey.ps1
- Run Powershell as an admin and type in
Set-ExecutionPolicy RemoteSigned
- Next run this command
Import-Module C:\Users\Master\Desktop\ProductKey.ps1; Get-WindowsKey
That’s it. Product key is displayed on the screen!
Cheers,
Help Tech News
Comments
Post a Comment