Get Serial Numbers of Currently-Attached USB Flash Drives

TL;DR – Run the following PowerShell command:

Get-WmiObject Win32_USBControllerDevice | % { [wmi]$_.Dependent } | Where-Object DeviceID -like "*USBSTOR*" | ForEach-Object { [PSCustomObject]@{ "FriendlyName" = $_.Caption; "SerialNumber" = $_.DeviceID.Split('\')[-1] } }

How it Works

  • Get-WmiObject Win32_USBControllerDevice gets a live list of every hardware device currently connected to a USB controller.

  • Where-Object DeviceID -like "*USBSTOR*" filters Mass Storage drives.

  • $_.DeviceID.Split('\')[-1] returns the end of the hardware path, which is the raw hardware serial number.

To get info for all USB Mass Storage drives that have ever been plugged into the system, the registry can be queried as follows:

Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*\" | Select-Object FriendlyName, PSChildName