This script is used to back up the windows products key on activated Windows 10, Windows 8.1 and Windows 8. The product key will be outputted in a txt file named “WindowsKeyInfo” on your windows desktop.
Scenarios
When IT pro needs to reinstall Windows OS on an activated Windows computer, he needs to reactivate the product key of the computer after OS installation. This script will help you to do so.
Prerequisites
Please ensure that your operation system is one of the Windows 8, Windows 8.1 or Windows 10 version.
Script
Powershell version
- Right click the script and run it with powershell
Figure 1. |
- Console will show key information and ask you for the need to save, please input “Y”
Figure 2. |
- The key information will be saved in a txt file named “WindowsKeyInfo” on your windows desktop
Figure 3. |
Here are some code snippets for your reference in Powershell.
#Convert binary to serial number Function ConvertToKey($Key) { $Keyoffset = 52 $isWin8 = [int]($Key[66]/6) -band 1 $HF7 = 0xF7 $Key[66] = ($Key[66] -band $HF7) -bOr (($isWin8 -band 2) * 4) $i = 24 [String]$Chars = "BCDFGHJKMPQRTVWXY2346789" do { $Cur = 0 $X = 14 Do { $Cur = $Cur * 256 $Cur = $Key[$X + $Keyoffset] + $Cur $Key[$X + $Keyoffset] = [math]::Floor([double]($Cur/24)) $Cur = $Cur % 24 $X = $X - 1 }while($X -ge 0) $i = $i- 1 $KeyOutput = $Chars.SubString($Cur,1) + $KeyOutput $last = $Cur }while($i -ge 0) $Keypart1 = $KeyOutput.SubString(1,$last) $Keypart2 = $KeyOutput.Substring(1,$KeyOutput.length-1) if($last -eq 0 ) { $KeyOutput = "N" + $Keypart2 } else { $KeyOutput = $Keypart2.Insert($Keypart2.IndexOf($Keypart1)+$Keypart1.length,"N") } $a = $KeyOutput.Substring(0,5) $b = $KeyOutput.substring(5,5) $c = $KeyOutput.substring(10,5) $d = $KeyOutput.substring(15,5) $e = $KeyOutput.substring(20,5) $keyproduct = $a + "-" + $b + "-"+ $c + "-"+ $d + "-"+ $e $keyproduct }
Download here.
Source: https://gallery.technet.microsoft.com/scriptcenter/How-to-backup-Windows-85379640
No comments:
Post a Comment