J'ai trouvé une solution possible à la question ici: http://youtu.be/71Vc9QiraQEComment trouver clé de produit Windows si votre autocollant est endommagé
Je ne suis pas un shell de pouvoir moi-même et ne peut pas tout à fait suivre le code dans le script.
Ce serait un script utile pour aider à réinstaller lorsque les systèmes d'exploitation ont été mis à niveau. Mon problème est que je voudrais le comprendre plus avant de l'utiliser ou au moins être dit qu'il semble inoffensif.
Voici le script:
function Get-WindowsKey {
## function to retrieve the Windows Product Key from any PC
param ($targets = ".")
$hklm = 2147483650
$regPath = "Software\Microsoft\Windows NT\CurrentVersion"
$regValue = "DigitalProductId"
Foreach ($target in $targets) {
$productKey = $null
$win32os = $null
$wmi = [WMIClass]"\\$target\root\default:stdRegProv"
$data = $wmi.GetBinaryValue($hklm,$regPath,$regValue)
$binArray = ($data.uValue)[52..66]
$charsArray = "B","C","D","E","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","5","6","7","8","9"
## decrypt base24 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
}
}
$win32os = Get-WmiObject Win32_OperatingSystem -computer $target
$obj = New-Object Object
$obj | Add-Member Noteproperty Computer -value $target
$obj | Add-Member Noteproperty Caption -value $win32os.Caption
$obj | Add-Member Noteproperty CSDVersion -value $win32os.CSDVersion
$obj | Add-Member Noteproperty OSArch -value $win32os.OSArchitecture
$obj | Add-Member Noteproperty BuildNumber -value $win32os.BuildNumber
$obj | Add-Member Noteproperty RegisteredTo -value $win32os.RegisteredUser
$obj | Add-Member Noteproperty ProductID -value $win32os.SerialNumber
$obj | Add-Member Noteproperty ProductKey -value $productkey
$obj
}
}
Get-WindowsKey
La première commande utilisée dans Windows PowerShell:
Set-ExecutionPolicy RemoteSigned
Si le premier script ne fonctionne pas, essayez ceci: j'ai pu obtenir ma clé en utilisant cela, mais j'ai dû corriger le script, en changeant la dernière ligne à:
function Get-WindowsKey {
# ...
}
Get-WindowsKey localhost
Le lien Youtube ne fonctionne pas ici. Mais il y a un autre billet de blog contenant le code sur http://www.randomtechtips.com/get-windows-product-key-using-powershell/ –