国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > PowerShell > 正文

PowerShell小技巧之讀取Windows產(chǎn)品密鑰

2020-03-26 19:14:41
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

之前大多數(shù)人可能用過(guò)VBS讀取Windows產(chǎn)品密鑰的VBS腳本,VBS腳本通常都比較隱晦、難懂,今天忙里偷閑,隨手寫(xiě)了一個(gè)用于讀取Windows產(chǎn)品密鑰的PowerShell腳本。

代碼如下:

 

復(fù)制代碼 代碼如下:

 =====文件名:Get-WindowsProductKey.ps1=====
function Get-WindowsProductKey([string]$computer)
{

 

$comments =@'
author:fuhj(powershell#live.cn ,http://fuhaijun.com)
example: Get-WindowsProductKey .
'@
$reg = [WMIClass] ("//" + $computer + "/root/default:StdRegProv")
$values = [byte[]]($reg.getbinaryvalue(2147483650,"SOFTWARE/Microsoft/Windows NT/CurrentVersion","DigitalProductId").uvalue)
$lookup = [char[]]("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9")
$keyStartIndex = [int]52;
$keyEndIndex = [int]($keyStartIndex + 15);
$decodeLength = [int]29
$decodeStringLength = [int]15
$decodedChars = new-object char[] $decodeLength
$hexPid = new-object System.Collections.ArrayList
for ($i = $keyStartIndex; $i -le $keyEndIndex; $i++){ [void]$hexPid.Add($values[$i]) }
for ( $i = $decodeLength - 1; $i -ge 0; $i--)
    {
     if (($i + 1) % 6 -eq 0){$decodedChars[$i] = '-'}
     else
       {
        $digitMapIndex = [int]0
        for ($j = $decodeStringLength - 1; $j -ge 0; $j--)
        {
            $byteValue = [int](($digitMapIndex * [int]256) -bor [byte]$hexPid[$j]);
            $hexPid[$j] = [byte] ([math]::Floor($byteValue / 24));
            $digitMapIndex = $byteValue % 24;
            $decodedChars[$i] = $lookup[$digitMapIndex];
         }
        }
     }
$STR = ''
$decodedChars | % { $str+=$_}
$STR
}

Get-WindowsProductKey .

 

執(zhí)行效果如下:

PowerShell,技巧,讀取,Windows,產(chǎn)品密鑰

 

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 吉林省| 恩平市| 河津市| 云和县| 阿拉善右旗| 石柱| 和田市| 托克逊县| 潮安县| 高雄市| 东乡县| 什邡市| 福安市| 阳泉市| 五台县| 五原县| 介休市| 报价| 西贡区| 潼关县| 叙永县| 策勒县| 临安市| 新平| 仁寿县| 麟游县| 饶河县| 溆浦县| 乡城县| 广元市| 铜川市| 凉城县| 普兰县| 咸丰县| 嘉荫县| 安仁县| 五家渠市| 泽州县| 曲阜市| 鸡泽县| 福鼎市|