我有大约 450 台运行 Windows 10 的 ASUS Chromebook,需要安装 Microsoft Office 2019。我为每台计算机都贴了单独的产品密钥贴纸,用于注册 Microsoft Office 2019。当我查看 COA 贴纸时,有两个条形码。
顶部条形码对应的值是 W2F-00188,另一个条形码对应的值是 04053000035198。显然,这不是 Office 2019 的产品密钥。我能否以某种方式将任一数字转换为 Office 2019 产品密钥的可扫描值?是否有某种方式可以自动执行为每台笔记本电脑输入条形码的过程,还是 Microsoft 希望最终用户手动输入完整的产品密钥?我想在 2021 年会有某种方式不必在每个单元上手动输入 450 个单独的产品密钥,但我认为在假设之前我应该在这里询问。
答案1
function Get-WindowsKey {
## function to retrieve the Windows Product Key from any PC
param ($targets = "$env:COMPUTERNAME")
$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
}
}