[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 13655
  • Last Modified:

How to get HARDWARE serial-number of hard-disk drives with WMI (or any other reliable API)

I am trying to get the HARDWARE Serial Numbers of hard-disk drives (which includes SSDs) with WMI (Windows Management Instrumentation):

Class: Win32_DiskDrive
Namespace: root\CIMV2

Now, a customer's computer contains 4 Western Digital hard-disk drives:

WDC WD2002FYPS-02W3B0 ATA Device
WDC WD2003FYYS-02W0B0 ATA Device
WDC WD3000GLFS-01F8U0 ATA Device
WDC WD30EZRX-00MMMB0 ATA Device

And these are the serial numbers of these 4 hard-disk drives I got with the above WMI query:

2020202057202d44435756413559323535303937
2020202057202d444d5759413030303834323931
2020202057202d445857354c3830353035313836
2020202057202d4443575741305a343930343730

Please note that these serial-numbers are very similar, so I cannot believe these are the real serial-numbers of these hard-disk drives.
So I used a professional hardware information program (HWiNFO) to compare these serial-numbers with those detected from HWiNFO, and they were totally different.

So I wonder whether it is possible to query the REAL hardware serial-numbers of hard-disk drives by using WMI?
0
PeterDelphin
Asked:
PeterDelphin
  • 9
  • 8
  • 3
  • +1
1 Solution
 
duncanb7Commented:
What is serial number you get from  (HWiNFO)  ? Could you send it us for comparsion ?


Duncan
0
 
PeterDelphinAuthor Commented:
These are the serial-numbers I get from HWiNFO:

Drive Serial Number:  WD-WCAVY5520579
Drive Serial Number:  WD-WMAY00802419
Drive Serial Number:  WD-WXL508051568
Drive Serial Number:  WD-WCAWZ0944007

Meanwhile I've also checked with another hardware information tool: These from HWiNFO are correct.
0
 
duncanb7Commented:
Could you try this on command line

wmic diskdrive list brief  /format:list

to see any different ?

Duncan
0
 
PeterDelphinAuthor Commented:
Here is the result of the command:

Caption=WDC WD2002FYPS-02W3B0 ATA Device
DeviceID=\\.\PHYSICALDRIVE1
Model=WDC WD2002FYPS-02W3B0 ATA Device
Partitions=3
Size=2000396321280

Caption=WDC WD2003FYYS-02W0B0 ATA Device
DeviceID=\\.\PHYSICALDRIVE2
Model=WDC WD2003FYYS-02W0B0 ATA Device
Partitions=1
Size=2000396321280

Caption=WDC WD3000GLFS-01F8U0 ATA Device
DeviceID=\\.\PHYSICALDRIVE3
Model=WDC WD3000GLFS-01F8U0 ATA Device
Partitions=2
Size=300066439680

Caption=WDC WD30EZRX-00MMMB0 ATA Device
DeviceID=\\.\PHYSICALDRIVE4
Model=WDC WD30EZRX-00MMMB0 ATA Device
Partitions=0
Size=3000590369280
0
 
duncanb7Commented:
the  serialnumber in your post seems size number for two disks

please try it one more

wmic diskdrive get serialnumber

Duncan
0
 
PeterDelphinAuthor Commented:
Here is the result:

2020202057202d44435756413559323535303937
2020202057202d444d5759413030303834323931
2020202057202d445857354c3830353035313836
2020202057202d4443575741305a343930343730
0
 
PeterDelphinAuthor Commented:
BTW, have you tried it yourself on your own computer and compared to the serial number in HWiNFO?
0
 
duncanb7Commented:
I also check your tools (hw32) and other internet tools on my driver  all are same serial and is different from
wmic but it is strange the number is closer to similar  and just swap between integer in the number

for example,
HDD_ID reports    WD-WXR1EB0TWS04
HW32 reports       WD-WXR1EB0TWS04
WMIC reports       W -DXW1RBET0SW40

You may be right. But Microsoft is huge company. How do you think to trust which one  ?

Duncan
0
 
duncanb7Commented:
And model number all correct on WMIC, HW32, HDD_ID
0
 
duncanb7Commented:
Could we mount off the disk drive and read the serial number on back side of the disk provided from manufacturer ? If possible, that will know which tools is more accurate. My computer is laptop that is hard to mount or take it off.


Duncan
0
 
PeterDelphinAuthor Commented:
OK, will try it tomorrow morning.
0
 
PeterDelphinAuthor Commented:
It's like I suspected: The serial numbers printed on the hardware are the same as I got from HWiNFO.

So the numbers from wmic are clearly wrong.
0
 
duncanb7Commented:
Great work, wmic is wrong on my laptiop and yours, and you also proved it from hardware.  Probably is wmic 's issue but the testing sample is small.  I will create new thread for  asking who will be interested to test wmic on window for serial number  to collect more statistic information that not just prove hw32 correct but also WMIC incorrect


Duncan
0
 
PeterDelphinAuthor Commented:
So is there any other reliable API (as asked in my question title) to get the serial-number of hard-disk drives?
0
 
duncanb7Commented:
I don't have such API,
To answer your question post, WMIC can not get the hard disk serial number.

Duncan
0
 
Gerald ConnollyCommented:
Why do you need the serial numbers?
0
 
PeterDelphinAuthor Commented:
I am a software developer. I need it to get a unique hardware ID for licensing purposes, and the hard-disk drive serial number is part of that.
0
 
Gerald ConnollyCommented:
Doesnt sound like a good plan. Disks change a lot, and some RAID controllers (probably all) give made up serial numbers, probably the same one on all systems.

I would of thought something like the MAC address would be a better bet?
0
 
PeterDelphinAuthor Commented:
Gerald Connolly wrote: "Doesnt sound like a good plan. Disks change a lot, and some RAID controllers (probably all) give made up serial numbers, probably the same one on all systems.

I would of thought something like the MAC address would be a better bet?
"

Oh come on, let this be my problem. The main topic here (as stated in the question title) is how to get the serial number, either with WMI or other API.
0
 
Rob MinersCommented:
If you only need the Serial Number and Hard drive identification try this I don't know if it will work on raid though as I can't test it.

wmic path win32_physicalmedia get SerialNumber, Tag

wmic path win32_physicalmedia get SerialNumber, Tag >%temp%\SerialNumber.txt & start notepad %temp%\SerialNumber.txt

I found it easier to combine two commands if you need the Model number.

wmic path win32_physicalmedia get SerialNumber, Tag & wmic diskdrive get model

wmic path win32_physicalmedia get SerialNumber, Tag >%temp%\SerialNumber.txt & wmic diskdrive get model >>%temp%\SerialNumber.txt & start notepad %temp%\SerialNumber.txt

It produces similar output to your first post.

Note:
This command line works straight up in 8.1

C:\WINDOWS\system32>wmic diskdrive get name, serialnumber, model
Model                          Name                SerialNumber
ST2000DM001-9YN164 ATA Device  \\.\PHYSICALDRIVE0  W1F1D6Y0
ST31000528AS ATA Device        \\.\PHYSICALDRIVE1  9VP8QB51

The same command line in Windows 7 produces the serial number in string format:


C:\Windows\system32>wmic diskdrive get name, serialnumber, model
Model                          Name                SerialNumber
ST2000DM001-9YN164 ATA Device  \\.\PHYSICALDRIVE0  202020202020202020202020315a304531563331
0
 
Gerald ConnollyCommented:
@peter, i was just trying to point out that in simple systems you may get the real Disk Serial number, but if the system is using RAID the OS may not even have access to the real Disks, it will only see the LUN presented by the RAID controller.
The serial number of this LUN will have been generated by the controller. NB Most controllers can do RAIDsets of 15 or more disks so they generate one. Is it going to be unique? Unlikely.
0
  • 9
  • 8
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now