Option 2: Find Serial Number in Powershell Step 1: Open Windows Powershell. Step 2: Enter the command below into PowerShell, and press Enter. Step 3: You will now see the tag (name) and serial number listed for your hard drives.
Active4 months ago
I want to get hard disk serial number. How I can I do that?I tried with two code but I am not getting
In this one I am not getting any Unique Serial number.
And Second one is
Here I am getting Muhammad Saqib
VolumeSerialNumber . But it is not unique one. If I format the hard disk, this will change. How Can I get this?
1,27011 gold badge2626 silver badges4040 bronze badges
JobyJoby
17411 gold badge22 silver badges1010 bronze badges
10 Answers
Hm, looking at your first set of code, I think you have retrieved (maybe?) the hard drive model. The serial # comes from
Win32_PhysicalMedia .
Get Hard Drive model
Sims 3 ambitions expansion pack free download. Get the Serial Number
Hope this helps :)
hims056
24.2k2424 gold badges9393 silver badges120120 bronze badges
SprunthSprunth
I have used the following method in a project and it's working successfully.
you can call the above method as mentioned below,
If you need a unique identifier, use a combination of these IDs.
SencySency
1,10066 gold badges3232 silver badges5454 bronze badges
huoxudong125huoxudong125
1,06622 gold badges1515 silver badges3838 bronze badges
Use 'vol' shell command and parse serial from it's output, like this.Works at least in Win7
PeksuPeksu
Tot Zam
4,52344 gold badges3535 silver badges5656 bronze badges
Brahim BourassBrahim Bourass
The best way I found is, download a dll from here
Then, add the dll to your project.
Then, add code:
Microsoft sql server instance. Then, call the hard disk ID from where you need it
Windows Get Serial Number Of Disk Drive
Note: go to properties of the dll in explorer and set 'Build action' to 'Embedded Resource'
Brian Webster
21.3k4343 gold badges132132 silver badges209209 bronze badges
Azhar BandriAzhar Bandri
Below a fully functional method to get hard disk serial number:
Anjan KantAnjan Kant
lxg
8,9221111 gold badges3333 silver badges5454 bronze badges
Denis IlyushchenkoDenis Ilyushchenko
Here is a solution using win32 api and std string in case you need your application to run on a OS with no CLR. I found it here on github.
IjonTichyIjonTichy
In case you want to use it for copy protection and you need it to return always the same serial on one computer (of course as far as first hdd or ssd is not changed) I would recommend code below. Dvd super multi driver. For ManagementClass you need to add reference to System.Management. P.S. Without 'InterfaceType' and 'DeviceID' check that method can return serial of random disk or serial of USB flash drive which connected to pc right now.
random onerandom one
Not the answer you're looking for? Browse other questions tagged c#hard-drive or ask your own question.
Active1 year, 6 months ago
I am archiving a large number of HDD's at my company, and I have a powershell script that grabs the hostname and user list from a Windows OS installation, and I would like to programatically find the serial number of the drive as well. I have the following bit of Powershell code (mostly completed) that should do this, but there's a complication as well.
I am connecting the drives with a USB HDD dock, and it seems that if the computer is booted with the drive connected internally (via SATA cables, I haven't tested externally yet), then the Machavity
SerialNumber field is populated. However, if I connect it after the computer has booted up, the SerialNumber https://renewarchive214.weebly.com/blog/pandigital-downloads-firmware. field is always blank. Is there a way to have the computer re-scan for this info when I connect the drive, or is this info only gathered at boot-up, for example, by the BIOS or something?
25.4k1515 gold badges6363 silver badges8383 bronze badges
AndrewAndrew
3 Answers
AFAIK the Frode F.Frode F.
SerialNumber is optional and provided by the driver. So if the USB-dock driver is not providing the information to Windows, then there's no easy way to retrieve it.
39.8k77 gold badges6363 silver badges8888 bronze badges
This thread (look for 'Maxim Shatskih') says that
IOCTL_SCSI_PASS_THROUGH is supported by USBSTOR , so it would be possible to write or find a program that can get the serial number from a USB attached drive, by passing the appropriate SCSI command to the drive (get mode page 80h).
A package that may do what you need is ΧpẘΧpẘ
sg3_utils for Windows (it was originally written for Linux but ported to Windows).
Windows Disk Serial Number
2,96211 gold badge77 silver badges1919 bronze badges
I just tested booting the computer up with the HDD in the USB dock, and I got the same result. Technically, the SerialNumber field wasn't blank, but was all zero's instead of the actual serial number, which is probably just the same difference. It's seeming like it may be more work than it's worth to do this as a part of the script (assuming it's even possible), so I will likely just continue scanning the SN barcode into the script. It's an extra step, but only takes a couple seconds.
Thanks everyone for the input.
AndrewAndrew
Get Disk Drive Serial NumberNot the answer you're looking for? Browse other questions tagged powershellwmiget-wmiobject or ask your own question.Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |