How do I use WMI to get the _correct_ serial number for HDDs? When I do: SELECT * FROM Win32_DiskDrive or SELECT * FROM Win32_PhysicalMedia I get serial numbers that do not match the actual HDD serial number - they are mangled in different ways.
I want to read the name and the serialnumber of my Hard-Drives. I stumbled upon wmic but i'm having troubles.
I guess these two commands should do the trick, but I only get the message: Invalid Xml-Content. //(Translated) wmic path win32physicalmedia get serialnumber or wmic DISKDRIVE GET SerialNumber I tried the following aswell: wmic DISKDRIVE GET SerialNumber /FORMAT:list wmic DISKDRIVE GET SerialNumber /FORMAT:xml.xsl wmic DISKDRIVE GET SerialNumber c: test.txt Any ideas on what I'am doing wrong? Solution: Thanks JPBlanc, via the /?
Command i've found out that SerialNumber doesn't even exist. I now use WMIC /output:'c: hdds.txt' DISKDRIVE GET PNPDeviceID,Name /Format:CSV which gives the correct result. You are just making a mistake usin WMIC command line, WMIC DISKDRIVE GET SerialNumber /Format /?
![Idm Idm](http://exar.ch/blog/wp-content/uploads/2013/07/resource-explorer.png)
![Wmi win32_disk drive serial numbers Wmi win32_disk drive serial numbers](http://i.stack.imgur.com/glSHI.png)
Gives you keywords: CSV HFORM HTABLE LIST MOF RAWXML TABLE VALUE XML htable-sortby htable-sortby.xsl texttablewsys texttablewsys.xsl wmiclimofformat wmiclimofformat.xsl wmiclitableformat wmiclitableformat.xsl wmiclitableformatnosys wmiclitableformatnosys.xsl wmiclivalueformat wmiclivalueformat.xsl you can try: WMIC /output:'c: temp serial1.xml' DISKDRIVE GET SerialNumber /Format:RAWXML You can replace RAWXML by one of the others formats. I was getting this error on Windows 7 x86 Pro (where querying the serial number ) when an external drive was connected. This is how I fixed it:. Get the ID of each drive: wmic diskdrive get deviceid /format:list. Parse the output and get the first ID. In my case this was. PHYSICALDRIVE0.
Escape the backslashes so that the ID is. PHYSICALDRIVE0. Get the serial number of the drive using its escaped ID: wmic diskdrive where deviceid='.
PHYSICALDRIVE0' get serialnumber /format:list. Repeat steps 2 - 4 until you have the serial numbers of all drives Edit: The above doesn't work on my copy of Windows XP x86 Pro. This does: wmic path win32physicalmedia where tag='. PHYSICALDRIVE0' get serialnumber /format:list.