PowerShell中獲取Windows系統(tǒng)序列號的腳本分享
更新時間:2014年11月26日 09:19:39 投稿:junjie
這篇文章主要介紹了PowerShell中獲取Windows系統(tǒng)序列號的腳本分享,本文方法是讀取注冊表中的信息,然后處理成序列號輸出,需要的朋友可以參考下
windows序列號可以直接在注冊表中讀取,PowerShell要做的只是讀出數(shù)據(jù)后稍作處理,讓它更像一個序列號。
復(fù)制代碼 代碼如下:
function Get-ProductKey {
$map="BCDFGHJKMPQRTVWXY2346789"
$value = (get-itemproperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").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
}
輸出結(jié)果為:
復(fù)制代碼 代碼如下:
PS> Get-ProductKey
VKTXG-GXXY3-W97QP-GP4PV-XXXXX
相關(guān)文章
Powershell從注冊表中查詢默認(rèn)MAPI客戶端的例子
這篇文章主要介紹了Powershell從注冊表中查詢默認(rèn)MAPI客戶端的例子2014-05-05PowerShell統(tǒng)計文件夾下文件個數(shù)的方法
這篇文章主要介紹了PowerShell統(tǒng)計文件夾下文件個數(shù)的方法,本文介紹了2種訪求實現(xiàn)這個需求,需要的朋友可以參考下2014-08-08Powershell創(chuàng)建簡潔的HTML報告例子
這篇文章主要介紹了Powershell創(chuàng)建簡潔的HTML報告例子,本文先是講解了實現(xiàn)的步驟,然后給出了實現(xiàn)代碼,需要的朋友可以參考下2014-11-11