gpt4 book ai didi

PowerShell小技巧之读取Windows产品密钥

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 24 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章PowerShell小技巧之读取Windows产品密钥由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

之前大多数人可能用过VBS读取Windows产品密钥的VBS脚本,VBS脚本通常都比较隐晦、难懂,今天忙里偷闲,随手写了一个用于读取Windows产品密钥的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] = '-'}      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 . 。

  。

执行效果如下:

PowerShell小技巧之读取Windows产品密钥

最后此篇关于PowerShell小技巧之读取Windows产品密钥的文章就讲到这里了,如果你想了解更多关于PowerShell小技巧之读取Windows产品密钥的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com