admin管理员组

文章数量:1530518

之前大多数人可能用过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