手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >PowerShell中获取Windows系统序列号的脚本分享
PowerShell中获取Windows系统序列号的脚本分享
摘要:windows序列号可以直接在注册表中读取,PowerShell要做的只是读出数据后稍作处理,让它更像一个序列号。复制代码代码如下:func...

windows序列号可以直接在注册表中读取,PowerShell要做的只是读出数据后稍作处理,让它更像一个序列号。

复制代码 代码如下:

function Get-ProductKey {

$map="BCDFGHJKMPQRTVWXY2346789"

$value = (get-itemproperty "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersion").digitalproductid[0x34..0x42]

$ProductKey = ""

for ($i = 24; $i -ge 0; $i--) {

$r = 0

for ($j = 14; $j -ge 0; $j--) {

$r = ($r * 256) -bxor $value[$j]

$value[$j] = [math]::Floor([double]($r/24))

$r = $r % 24

}

$ProductKey = $map[$r] + $ProductKey

if (($i % 5) -eq 0 -and $i -ne 0) {

$ProductKey = "-" + $ProductKey

}

}

$ProductKey

}

输出结果为:

复制代码 代码如下:

PS> Get-ProductKey

VKTXG-GXXY3-W97QP-GP4PV-XXXXX

【PowerShell中获取Windows系统序列号的脚本分享】相关文章:

PowerShell中判断闰年的方法

Powershell获取图片名字、文件夹及拍摄时间的例子

PowerShell函数中使用$PSBoundParameters获取输入参数列表实例

PowerShell中字符串使用单引号和双引号的区别

Powershell获取环境变量的方法

Powershell改变脚本执行优先权的代码分享

PowerShell小技巧之查找获取注册表路径

PowerShell中执行Javascript的方法示例

Powershell小技巧之获取字符串的行数

Powershell小技巧之获取变量列表

精品推荐
分类导航