Una rapida pillola nel caso tu avessi necessità di recuperare la Product Key di un Microsoft Office già installato a bordo macchina, senza però avere il certificato originale o equivalente elettronico (registrato tramite account Microsoft). Il problema è aggirabile tramite PowerShell e uno script originale realizzato e pubblicato su WinAero (qui l’articolo originale: winaero.com/blog/how-to-get-microsoft-office-product-key-without-using-third-party-software).
Avvia un prompt di PowerShell come amministratore, salva e scompatta questo script (che trovi anche qui di seguito per comodità), quindi lancialo per ottenere a video ciò che desideri:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-MSOfficeProductKey { | |
param( | |
[string[]]$computerName = "." | |
) | |
$product = @() | |
$hklm = 2147483650 | |
$path = "SOFTWARE\Microsoft\Office" | |
foreach ($computer in $computerName) { | |
$wmi = [WMIClass]"\\$computer\root\default:stdRegProv" | |
$subkeys1 = $wmi.EnumKey($hklm,$path) | |
foreach ($subkey1 in $subkeys1.snames) { | |
$subkeys2 = $wmi.EnumKey($hklm,"$path\$subkey1") | |
foreach ($subkey2 in $subkeys2.snames) { | |
$subkeys3 = $wmi.EnumKey($hklm,"$path\$subkey1\$subkey2") | |
foreach ($subkey3 in $subkeys3.snames) { | |
$subkeys4 = $wmi.EnumValues($hklm,"$path\$subkey1\$subkey2\$subkey3") | |
foreach ($subkey4 in $subkeys4.snames) { | |
if ($subkey4 -eq "digitalproductid") { | |
$temp = "" | select ComputerName,ProductName,ProductKey | |
$temp.ComputerName = $computer | |
$productName = $wmi.GetStringValue($hklm,"$path\$subkey1\$subkey2\$subkey3","productname") | |
$temp.ProductName = $productName.sValue | |
$data = $wmi.GetBinaryValue($hklm,"$path\$subkey1\$subkey2\$subkey3","digitalproductid") | |
$valueData = ($data.uValue)[52..66] | |
# decrypt base24 encoded binary data | |
$productKey = "" | |
$chars = "BCDFGHJKMPQRTVWXY2346789" | |
for ($i = 24; $i -ge 0; $i–) { | |
$r = 0 | |
for ($j = 14; $j -ge 0; $j–) { | |
$r = ($r * 256) -bxor $valueData[$j] | |
$valueData[$j] = [math]::Truncate($r / 24) | |
$r = $r % 24 | |
} | |
$productKey = $chars[$r] + $productKey | |
if (($i % 5) -eq 0 -and $i -ne 0) { | |
$productKey = "-" + $productKey | |
} | |
} | |
$temp.ProductKey = $productKey | |
$product += $temp | |
} | |
} | |
} | |
} | |
} | |
} | |
$product | |
} | |
Get-MSOfficeProductKey |
Io ho effettuato i test con Windows 10 e Office 2016 ProPlus. Pur non ottenendo il nome del prodotto in prima colonna (sarebbe dovuto saltare fuori), il Product Key viene mostrato correttamente (due volte, su più test e diverse macchine, anche questo è strano, ma poco male):
Potrai ora reinstallare e registrare nuovamente Office 2016 sulla stessa macchina o su un’altra (nel caso di Office 2016 legato a Office 365, hai il limite delle 5 installazioni contemporanee massime).
Buon lavoro.
L'articolo potrebbe non essere aggiornato
Questo post è stato scritto più di 5 mesi fa, potrebbe non essere aggiornato. Per qualsiasi dubbio ti invito a lasciare un commento per chiedere ulteriori informazioni! :-)