Solved

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

Posted on 2014-07-28
21
7,418 Views
Last Modified: 2016-06-26
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
Comment
Question by:PeterDelphin
  • 9
  • 8
  • 3
  • +1
21 Comments
 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
What is serial number you get from  (HWiNFO)  ? Could you send it us for comparsion ?


Duncan
0
 

Author Comment

by:PeterDelphin
Comment Utility
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
 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
Could you try this on command line

wmic diskdrive list brief  /format:list

to see any different ?

Duncan
0
 

Author Comment

by:PeterDelphin
Comment Utility
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
 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
the  serialnumber in your post seems size number for two disks

please try it one more

wmic diskdrive get serialnumber

Duncan
0
 

Author Comment

by:PeterDelphin
Comment Utility
Here is the result:

2020202057202d44435756413559323535303937
2020202057202d444d5759413030303834323931
2020202057202d445857354c3830353035313836
2020202057202d4443575741305a343930343730
0
 

Author Comment

by:PeterDelphin
Comment Utility
BTW, have you tried it yourself on your own computer and compared to the serial number in HWiNFO?
0
 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
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
 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
And model number all correct on WMIC, HW32, HDD_ID
0
 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:PeterDelphin
Comment Utility
OK, will try it tomorrow morning.
0
 

Author Comment

by:PeterDelphin
Comment Utility
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
 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
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
 

Author Comment

by:PeterDelphin
Comment Utility
So is there any other reliable API (as asked in my question title) to get the serial-number of hard-disk drives?
0
 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
I don't have such API,
To answer your question post, WMIC can not get the hard disk serial number.

Duncan
0
 
LVL 16

Expert Comment

by:Gerald Connolly
Comment Utility
Why do you need the serial numbers?
0
 

Author Comment

by:PeterDelphin
Comment Utility
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
 
LVL 16

Expert Comment

by:Gerald Connolly
Comment Utility
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
 

Author Comment

by:PeterDelphin
Comment Utility
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
 
LVL 14

Accepted Solution

by:
Rob Miners earned 500 total points
Comment Utility
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
 
LVL 16

Expert Comment

by:Gerald Connolly
Comment Utility
@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

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
From individual freelancers to a staff of full-timers, creative professionals are continually creating new content for clients.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now