[英]powershell (Get-WmiObject win32_physicalmedia).serialnumber output hex
When I used (Get-WmiObject win32_physicalmedia).serialnumber
the output was in hex.当我使用
(Get-WmiObject win32_physicalmedia).serialnumber
,输出是十六进制的。 Example: 31323334353637383930
.示例:
31323334353637383930
。 Then then I used the code below然后我使用了下面的代码
$pass=""
$t=(Get-WmiObject win32_physicalmedia).serialnumber
$t -split '(.{2})' |%{ if ($_ -ne "") { $pass+=[CHAR]([CONVERT]::toint16("$_",16)) }}
write host $pass
The output was: 1234567890
.输出为:
1234567890
。 The problem is that 1234567890
is not the serial number -- the real serial number is 2143658709
.问题是
1234567890
不是序列号——真正的序列号是2143658709
。 I need a script to swap the number $input "1234567890"
to $output "214365768709"
.我需要一个脚本来将数字
$input "1234567890"
交换为$output "214365768709"
。
this presumes your SN string is an even number of characters, and that the real number simply reverses the character pairs.这假定您的 SN 字符串是偶数个字符,并且实数只是反转字符对。
$InString = '1234567890'
$OutString = ''
foreach ($Index in 0..($InString.Length / 2))
{
$CurPos = $Index * 2
$OutString += $InString[$CurPos + 1] + $InString[$CurPos]
}
$OutString
output = 2143658709
输出 =
2143658709
I think this is called "middle endian" format, where every two bytes are reversed: middle-endian我认为这称为“中端”格式,其中每两个字节颠倒一次:中端
Coming from a post here: WMI Win32_PhysicalMedia SMART ID in Vista and 7 Permissions来自此处的帖子: Vista 中的 WMI Win32_PhysicalMedia SMART ID 和 7 权限
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.