Show-Header Starting with this number: $number = 26443007 $number
Show-Header Display the bits for this number: $bits = [Convert]::ToString($number,2) $bits
Show-Header Add missing leading zeroes: # pad the string to its full bit range (32 bits) $bitsAligned = $bits.PadLeft(32, '0') $bitsAligned
Show-Header Display the four byte groups $bitsAligned-split'(?<=\G.{8})(?=.)'-join'-'
Show-Header Get the bytes by conversion to IPAddress object: $bytes = ([Net.IPAddress]$number).GetAddressBytes() $bytes
Show-Header Display the bits for the IPAddress bytes: $bitbytes = $bytes | ForEach-Object { [Convert]::ToString($_, 2).PadLeft(8,'0')} $bitbytes-join'-'
Show-Header Show the Least Significant Byte LSB: $bytes[0]
Show-Header Show LSB by turning the 8 bits to the right into a number to verify: $bits = [Convert]::ToString($number, 2) # take least significant bits [Convert]::toByte($bits.Substring($bits.Length-8),2)
Show-Header Show the Most Significant Byte MSB: $bytes[3]
===========================Starting with this number:===========================
26443007
=======================Display the bits for this number:========================
1100100110111110011111111
===========================Add missing leading Zeroes:==========================
00000001100100110111110011111111
==========================Display the four byte groups==========================
00000001-10010011-01111100-11111111
================Get the bytes by conversion to IPAddress object:================
255
124
147
1
===================Display the bits for the IPAddress bytes:====================
11111111-01111100-10010011-00000001
======================Show the Least Significant Byte LSB:======================
255
======Show LSB by turning the 8 bits to the right into a number to verify:======
255
=======================Show the Most Significant Byte MSB:======================
1
多数 Windows 许可证激活任务可以通过一个古老的名为 slmgr.vbs 的 VBScript 来实现自动化。不过,用这个工具来获取信息的意义不大。因为 slmgr.vbs 使用的事本地化的字符串,并且将所有数据转换为一个大字符串格式。
一个更好的方法是跳过 slmgr.vbs,而直接查询信息源。要搞清 slmgr.vbs 如何实现这些功能,您可以查看该脚本的源码。请在 PowerShell ISE 中运行这段代码:
1 2 3 4
# get the path to the script file $Path = Get-Command slmgr.vbs | Select-Object-ExpandProperty Source # load the script file $file = $psise.CurrentPowerShellTab.Files.Add($Path)
This command is actually an ancient VBScript. To read all of your license settings, for example, try this: 这个命令实际上是一个古老的 VBScript。例如要读取所有许可证设置,请使用以下代码: