admin管理员组文章数量:1654021
之前大多数人可能用过VBS读取Windows产品密钥的VBS脚本,VBS脚本通常都比较隐晦、难懂,今天忙里偷闲,随手写了一个用于读取Windows产品密钥的PowerShell脚本。
代码如下:
=====文件名:Get-WindowsProductKey.ps1=====
Get-WindowsProductKey([]$computer)
{
$comments =@'
'@
$reg = [WMIClass] ( + $computer + )
$values = [byte[]]($reg.getbinaryvalue(2147483650,,).uvalue)
$lookup = [char[]](,,,,,,,,,,,,,,,,,,,,,,,)
$keyStartIndex = []52;
$keyEndIndex = []($keyStartIndex + 15);
$decodeLength = []29
$decodeStringLength = []15
$decodedChars = char[] $decodeLength
$hexPid = System.Collections.ArrayList
($i = $keyStartIndex; $i $keyEndIndex; $i++){ [void]$hexPid.Add($values[$i]) }
( $i = $decodeLength - 1; $i 0; $i--)
{
(($i + 1) 6 0){$decodedChars[$i] = '&
{
$digitMapIndex = []0
($j = $decodeStringLength - 1; $j 0; $j--)
{
$byteValue = [](($digitMapIndex * []256) [byte]$hexPid[$j]);
$hexPid[$j] = [byte] ([math]::Floor($byteValue / 24));
$digitMapIndex = $byteValue 24;
$decodedChars[$i] = $lookup[$digitMapIndex];
}
}
}
$STR =
$decodedChars | { $str+=$_}
$STR
}
Get-WindowsProductKey .
执行效果如下:
作者: 付海军
出处:http://fuhj02blogs
版权:本文版权归作者和博客园共有
转载:欢迎转载,为了保存作者的创作热情,请按要求【转载】,谢谢
要求:未经作者同意,必须保留此段声明;必须在文章中给出原文连接且保证内容完整!否则必究法律责任!
个人网站: http://www.fuhaijun/
转载于:https://wwwblogs/fuhj02/p/3351172.html
本文标签: 密钥产品powershellWindows
版权声明:本文标题:PowerShell读取Windows产品密钥 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1725343730a1019743.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论