简体   繁体   English

powershell (Get-WmiObject win32_physicalmedia).serialnumber 输出十六进制

[英]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.

相关问题 PowerShell Get-WmiObject WIN32_VOLUME WHERE子句 - PowerShell Get-WmiObject WIN32_VOLUME WHERE clause 将Get-WmiObject win32_diskdrive转换为Powershell 4中的阵列 - Convert Get-WmiObject win32_diskdrive to array in Powershell 4 Powershell get-netadapter与frrom get-wmiobject win32_networkadapter不同 - Powershell get-netadapter differs frrom get-wmiobject win32_networkadapter powershell的Get-WmiObject -Win32_Share类返回空路径 - powershell's Get-WmiObject -Class Win32_Share returns null paths Powershell:从get-wmiobject win32_product过滤不需要的值 - Powershell: Filtering unwanted values from get-wmiobject win32_product 在 GUI 窗体上获取 Get-WmiObject -Class Win32_Product 输出 - Get Get-WmiObject -Class Win32_Product Output on GUI Form 查询多个电池Powershell脚本get-wmiobject win32_battery - query multiple batteries powershell script get-wmiobject win32_battery Get-WMIObject无法枚举增强的Powershell中的Win32_LogicalDiskToPartiion - Get-WMIObject fails to enumerate Win32_LogicalDiskToPartiion in elevated powershell 为什么Powershell中的Get-WMIObject Win32_Process这么慢,有哪些替代方案? - Why is Get-WMIObject Win32_Process in Powershell so slow and what are the alternatives? Get-WMIObject -class Win32_ComputerSystem | 选择用户名返回空输出 - Get-WMIObject -class Win32_ComputerSystem | select username returns an empty output
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM