How do I find the Serial Number of a USB Drive?

Posted on

QUESTION :

I’m trying to re-enable USB Autoplay in a secure way, by installing a program on each of the computers that I use so that I can run my launcher (PStart in this case) whenever I plug in my specific USB drive. The tool that I’m using to enable this – AutoRunGuard – needs the serial number of the USB drive that I am using. I can’t figure out where to find this in Windows. Ideally I would not need to install and run a separate program to do this (seemingly) simple task.

Since this is a pretty easy question, bonus points if you also tell me how to discover it in Linux as well.

What steps do I need to take to retrieve a USB Drive’s serial number?

UPDATE:
Just incase people come here looking for the answer for AutoRunGuard, I discovered that they don’t want the USB device serial number, but the volume serial number. The drive serial can be found by going into the command line, navigating to the drive, and executing dir. The volume serial number is found in the top two lines – use it without the dash.

ANSWER :

Use the freeware USBDeview:

USBDeview is a small utility that
lists all USB devices that currently
connected to your computer, as well as
all USB devices that you previously
used. For each USB device, exteneded
information is displayed: Device
name/description, device type, serial
number (for mass storage devices), the
date/time that device was added,
VendorID, ProductID, and more…
USBDeview also allows you to uninstall
USB devices that you previously used,
and disconnect USB devices that are
currently connected to your computer.
You can also use USBDeview on a remote
computer, as long as you login to that
computer with admin user.

alt text

On Linux, usbview will do this, just click on the device in the left pane.

Get USB Serial Numbers on Windows with PowerShell

Here’s a PowerShell solution that will give you the serial number of all “USB Mass Storage Devices” mounted on the system which you run it. It uses Get-CIMInstance to query the Win32_PnPSignedDriver class to get the property values with filtering, looping, setting a couple variables, using a method, etc.

Within the PowerShell script below, I left some commented out logic and comments for running with the legacy Get-WMIObject cmdlet for systems with versions below PowerShell 3.0.

PowerShell

$DevId = (((Get-CimInstance -Class win32_PnPSignedDriver) | ?{($_.Description -like '*mass*')}).DeviceID);
$DevSerial = @($DevId | %{$_.Split('')[2]});
$DevSerial

##### // Everything below is commented out with comments for each section \ #####

## -- See everything or the selected properties per above
#((Get-CimInstance -Class win32_PnPSignedDriver) | ?{($_.Description -like '*mass*')}) | 
#Select Description, DeviceClass, DeviceID, Manufacturer

## -- Correlated legacy PS code older than PowerShell version 3
#$DevId = ((Get-WmiObject Win32_USBControllerDevice | %{[wmi]($_.Dependent)} | ?{($_.Description -like '*mass*')}).DeviceID);
#$DevSerial = @($DevId | %{$_.Split('')[2]});
#$DevSerial

## -- See everything or selected properties per above legacy PS code
#Get-WmiObject Win32_USBControllerDevice | %{[wmi]($_.Dependent)} | ?{($_.Description -like '*mass*')} | 
#Select Description, DeviceID, Manufacturer, Service

Supporting Resources

Under Windows 7.1 Right Click ‘Computer’ -> ‘Manage’ -> ‘Device Manager’ -> Navigate to your USB Drive, Right Click -> Properties -> Details, Property->Parent

Value:

USBVID_1058&PID_0830575833314133343231313937

The USB unique id is all the characters after the last , in this case 575833314133343231313937

You can also be able to extract it from Property->Device Instance Path, however that includes some other fields after the USB unique id part, so is slightly harder to read off.

Leave a Reply

Your email address will not be published. Required fields are marked *