濮阳杆衣贸易有限公司

主頁 > 知識庫 > PowerShell小技巧之讀取Windows產(chǎn)品密鑰

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

熱門標簽:騰訊地圖標注中心怎么標注 地圖標注的圖案 萬全縣地圖標注app 如何根據(jù)經(jīng)緯度百度地圖標注 莫拉克電梯系統(tǒng)外呼怎么設置 電話機器人公司招聘 印臺區(qū)呼叫中心外呼系統(tǒng) 新鄭電銷機器人一個月多少錢 六寸地圖標注點怎么刪除

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

代碼如下:

復制代碼 代碼如下:

 =====文件名: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] = '#45;'}
     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小技巧之發(fā)送TCP請求
  • PowerShell小技巧之嘗試ssh登錄
  • PowerShell小技巧之執(zhí)行SOAP請求
  • PowerShell腳本開發(fā)之對指定IP進行端口掃描
  • PowerShell腳本開發(fā)之收發(fā)TCP消息包
  • PowerShell腳本開發(fā)之收發(fā)UDP消息包

標簽:疫苗接種 天水 南昌 襄陽 臨汾 湘潭 喀什 汕頭

巨人網(wǎng)絡通訊聲明:本文標題《PowerShell小技巧之讀取Windows產(chǎn)品密鑰》,本文關鍵詞  PowerShell,小,技巧,之,讀取,;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《PowerShell小技巧之讀取Windows產(chǎn)品密鑰》相關的同類信息!
  • 本頁收集關于PowerShell小技巧之讀取Windows產(chǎn)品密鑰的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    会泽县| 河东区| 宜阳县| 马公市| 黎城县| 洛扎县| 虞城县| 凌源市| 富平县| 利川市| 石柱| 唐河县| 肇州县| 永靖县| 孝义市| 三明市| 安阳市| 尉犁县| 满洲里市| 南岸区| 湄潭县| 织金县| 禄劝| 平潭县| 吉林省| 宁武县| 湖州市| 土默特左旗| 儋州市| 唐河县| 襄汾县| 康保县| 甘德县| 许昌市| 江山市| 南郑县| 开平市| 伊通| 逊克县| 郓城县| 雷州市|