- El Hardware ID uniquely identifies each device and Windows He uses it to driverslicenses and security.
- PowerShell allows you to easily list and filter the USB ID with cmdlets like Get-PnpDevice and WMI classes.
- It is possible to automate the tracking of USB devices with scripts that send data to a central server via REST API.
- Tools like Device administrator and USBView facilitate the reading of VID/PID and other key fields of the USB descriptor.
If you've ever plugged in a USB drive and your computer started acting strangely, or Windows displayed a mysterious error message, the problem is likely related to the USB device's Hardware ID . Knowing how to locate this ID using PowerShell and other built-in Windows tools is a skill that can save you a lot of headaches, especially in business environments where installing third-party software is restricted.
Furthermore, many companies are required to monitor which USB devices are connected, register their IDs, and maintain traceability for security and regulatory compliance purposes. From preventing data leaks to stopping malware from entering via an infected USB drive, everything hinges on properly identifying each device. Here you will see, in considerable detail, how the HWID works, how to obtain the USB ID using PowerShell and other tools, and how to use that information both to diagnose problems and to automate device tracking.
What is a Hardware ID (HWID) and why should you care?
The Hardware ID, or HWID, is a unique digital identifier associated with each physical component of your computer: motherboard, hard drive, graphics card, network adapters, USB controllers, etc. It is often called the device's "fingerprint" because it serves to differentiate it from others, even when two computers appear identical.
On a typical PC, the operating system combines the HWIDs of several major components to build a global machine identity . This identity is crucial for things like software licenses tied to a specific machine , IT asset tracking, and many security processes that need to ensure a program only runs on authorized hardware.
This identifier isn't simply created by Windows: each piece of hardware has its own ID recorded in the firmware (for example, in the device's EEPROM). The operating system reads this information and generates identifier strings that then appear in Device Manager, PowerShell, or commands like wmic.
When you first install the operating system, Windows takes a snapshot of that hardware configuration and generates a set of identifiers linked to that machine. If you later change something major, such as a motherboard, the set of HWIDs can change enough to trigger license verification again or even require system reactivation in some products.
How to build a USB device identifier
In the case of USB devices, the HWID is derived from a very specific descriptor: the USB device descriptor (USB_DEVICE_DESCRIPTOR) . It is a data structure that every USB device must provide and that describes its basic characteristics: class, supported USB version, manufacturer, product, etc.
Within that descriptor, there are two key fields: idVendor and idProduct . The first identifies the manufacturer (Vendor ID or VID), and the second the specific product model (Product ID or PID). Using these values, Windows constructs strings like USB\VID_XXXX&PID_YYYY… which you then see as “Hardware IDs” in Device Manager.
For example, a Microsoft USB webcam might have something like idVendor = 0x045E (Microsoft) and idProduct = 0x0728 . That pair of values, along with the device version number ( bcdDevice ) and other fields, are combined to form the hardware IDs and compatible IDs that Windows uses to match the correct driver.
The bcdUSB field in the descriptor indicates the version of the USB specification to which the device conforms (for example, 0x0200 for USB 2.0). This helps the USB driver stack know how to communicate with the device, what speeds it supports, and what configuration options are available.
An important detail is that a USB device should not change its descriptor information while connected , even when its power state changes. It may display different information depending on whether it's connected at high speed or full speed, but this is determined at the time of connection.
From the driver side, the host obtains this descriptor via a GET_DESCRIPTOR control transfer directed to the device . On Windows, kernel-mode drivers (KMDF/UMDF/WDM) can formally request this descriptor through URBs (USB request blocks) or the framework's API, but that falls under driver development, not PowerShell administration.
View the USB Hardware ID using Windows graphical tools

Before diving into PowerShell, it's worth remembering that Windows offers several straightforward graphical ways to view the HWIDs of any device . These are especially useful when you only need to identify a specific device.
1. Device Manager
The quickest way, without writing a single line of code, is to use the Windows Device Manager . It works for any type of hardware, including USB storage devices , printers, webcams, etc.
- Open Device Manager by pressing Win + X and selecting “Device Manager”, or by searching for “devmgmt.msc”.
- Locate the component, for example in “Universal Serial Bus Controllers” or “Disk Drives” if it's a USB drive.
- Right-click on the problematic device and enter Properties.
- Go to the tab Details.
- In the “Property” dropdown menu, select Hardware IDs.
You'll see a list of strings; the most specific one usually includes VID, PID, and sometimes the serial number or SUBSYS. These are the strings you can then use in scripts or driver searches , copying them exactly as they are.
2. Command Prompt with WMIC
If you prefer a console option but don't want to touch PowerShell yet, you can use wmic (it's deprecated in modern versions, but you'll still find it on many computers):
wmic path win32_pnpentity get name, deviceid
This command displays all Plug and Play devices and their DeviceIDs , which are precisely the hardware IDs we're interested in. You can then visually filter the output or save it to a file for further processing.
3. Third-party applications (when permitted)
In environments where it is permitted, it is common to use tools like CPU-Z, Speccy, or HWiNFO to obtain a complete system overview, including the HWID of many components. However, in many companies this option is prohibited, so PowerShell becomes the Swiss Army knife accepted by security policies.
Obtain the USB hardware ID from PowerShell
PowerShell includes powerful cmdlets for viewing and filtering information about Plug and Play devices. For HWID purposes, the most useful is Get-PnpDevice , although older WMI classes are still used in some legacy scripts.
List hardware IDs with Get-PnpDevice
To view the identifiers of all active devices on the system, you can use:
Get-PnpDevice -PresentOnly | Select-Object -Property Name,InstanceId
This command returns a table with the device's friendly name and its InstanceId . That InstanceId is precisely the hardware ID string (or very close to it) that you can then relate to errors, system events, or driver searches.
If you want to focus only on PCI devices , for example, you could filter with:
Get-PnpDevice | Where-Object { $_.InstanceId -match '^PCI' } | Select-Object FriendlyName, InstanceId
And for USB devices, you can use a similar filter on the InstanceId string, changing the prefix:
Get-PnpDevice | Where-Object { $_.InstanceId -like 'USB\VID_*' } | Select-Object FriendlyName, InstanceId
Real-life cases: Identifying a problematic USB drive by its ID
A very common scenario is the following: your PC freezes, you look at the Event Viewer and find a reference to a device like "USB\VID_1F75&PID_0917\8&31abfd78&0&3" . You search through Device Manager looking for that ID and there's no way to know what it is exactly.
Practical example: In these situations, it's very useful to use PowerShell to cross-reference the information. For example, you can try to locate any PnP device whose InstanceId starts with that pattern:
Get-PnpDevice -InstanceId 'USB\VID_1F75*'
If this returns nothing (sometimes happens if the device is no longer connected), you can check the USB device history using WMI or, when allowed, with tools like USBDeview that show all devices that have ever been connected, including dates and ports.
View properties: If you get results, you can expand them with:
Get-PnpDevice -InstanceId 'USB\VID_1F75*' | Get-PnpDeviceProperty
This should list all the Plug and Play properties associated with the device , although if the device is not present or there is a permissions issue, you might receive empty or partial results. To export the information to a CSV file, the idea would be:
Get-PnpDevice -InstanceId 'USB\VID_1F75*' | Get-PnpDeviceProperty | Export-Csv -Path 'DevDetails.csv' -NoTypeInformation
If the CSV appears empty, it almost always means that no device matches the filter at that time or that the cmdlet could not read the properties (due to permissions or because the device is not responding).
View USB storage devices connected with WMI
Another typical case is wanting to know which USB drives or disks are currently connected . A classic PowerShell shortcut is to use the Win32_DiskDrive WMI class, filtering by interface type:
Get-WmiObject Win32_DiskDrive | Where-Object { $_.InterfaceType -eq 'USB' }
If you want something more readable and exportable, you can project only the relevant fields using a PSCustomObject:
Get-WmiObject Win32_DiskDrive | Where-Object { $_.InterfaceType -eq 'USB' } | ForEach-Object {
[PSCustomObject]@{
DeviceID = $_.DeviceID
Model = $_.Model
Serial = (Get-WmiObject Win32_PhysicalMedia | Where-Object { $_.Tag -eq $_.DeviceID }).SerialNumber
}
}
Here, each custom object displays the device identifier, model, and physical serial number (when properly exposed by the manufacturer). This is a very useful foundation for inventory and tracking scripts.
Automatically monitor and log USB devices with PowerShell
In corporate environments, it's very common for the IT department to want a centralized log of all USB devices connected to each machine: which device it was, when it was connected, from which computer, etc. This helps detect unauthorized devices, investigate security incidents, and ensure compliance with internal policies.
A flexible way to do this without additional licenses is to create a PowerShell script that collects the relevant information from each USB device and sends it to a central server via a REST API . Building on the previous example with WMI, the scheme would look something like this:
Get-WmiObject Win32_DiskDrive | Where-Object { $_.InterfaceType -eq “USB” } | ForEach-Object {
[PSCustomObject]@{
DeviceID = $_.DeviceID
Model = $_.Model
Serial = (Get-WmiObject Win32_PhysicalMedia | Where-Object { $_.Tag -eq $_.DeviceID }).SerialNumber
}
} | ConvertTo-Json | Invoke-RestMethod -Uri «http://servidorcentral/api/usblog» -Method Post
This block collects all disks with a USB interface, prepares objects with the key data, and serializes them to JSON . Then, using Invoke-RestMethod , it sends that JSON to an HTTP endpoint on your logging server. From there, your imagination (and security requirements) takes over: you can add the computer name, the session user, the exact date and time, and so on.
For continuous monitoring, the script is usually combined with the Windows Task Scheduler to run at system startup or login, or a service can be created that monitors system events related to USB connections and triggers real-time transmission.
Create a simple REST API to log USB data
To receive the data sent by the PowerShell script, you need a small web server with a route configured to accept POST requests with JSON . A very quick way to do this is using Python with Flask , which allows you to set up an endpoint with just a few lines of code.
The basic idea is this:
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/api/usblog', methods=['POST'])
def log_usb_data():
data = request.get_json()
if not data:
return jsonify({"error": "No data sent"}), 400
with open("usb_log.txt", "a") as log_file:
log_file.write(f»{data}\n»)
return jsonify({"message": "Data received successfully"}), 200
if __name__ =='__main__':
app.run(host='0.0.0.0′, port=5000)
With this, every call from your PowerShell scripts will add a line with the USB device data to the usb_log.txt file . Obviously, in a real-world deployment you'll want to send this data to a database, add authentication, encrypt traffic with HTTPS, etc., but as a starting point, this is more than sufficient.
Requirements: The basic steps to get it up and running would be:
- Install Flask with pip install flask on your Python server.
- Save the code in a server.py and launch it with python server.py.
- Configure the URL in PowerShell scripts to point to http://IP_DEL_SERVIDOR:5000/api/usblog.
From there, any team that has permission to contact that server will be able to send its inventory of USB devices periodically or on demand.
Schedule USB scripts to run at Windows startup
For this entire system to be practical, it's important that the PowerShell script launches automatically without anyone having to remember to run it . Windows offers two commonly used methods: Task Scheduler and the Startup folder.
Using Task Scheduler
Quick setup: With the Task Scheduler you can configure execution in response to different system events:
- Open Task Scheduler and choose “Create task”.
- On the “General” tab, give a name like “USB Tracking” and select “Run with the highest privileges”.
- In “Triggers”, he adds one for “When the system starts” or “When I log in”, depending on what interests you.
- In “Actions”, select “Start a program” and point to powershell.exe with parameters type -NoProfile -ExecutionPolicy Bypass -File «C:\path\script.ps1».
- Save and verify that the task is enabled.
This ensures that monitoring starts every time the computer is started and that the script can access all the necessary information, provided it has the appropriate permissions.
Using the Home folder with a .bat file
Another simpler, though less granular, option is to create a .bat file that calls PowerShell and place it in the user's Home folder:
powershell.exe -NoProfile -ExecutionPolicy Bypass -File «C:\path\del\script.ps1»
You save that as, for example, rastro_usb.bat , and copy it to:
%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
As soon as the user logs in, Windows will run that .bat file and, with it, the PowerShell script . This is a useful solution for small environments or when you don't want to deal with the Task Scheduler.
Track USB devices on remote computers using PowerShell
In many corporate networks, the problem isn't just knowing which USB device is connected to your own computer, but having a comprehensive view of all connected devices across multiple computers . When third-party agents can't be used, combining PowerShell Remoting and WMI remains a very viable solution.
A typical example of a script to list USB devices on multiple computers would look something like this:
$computer = «COMPUTER1″,»COMPUTER2″,»COMPUTER3»
$namespace = "root\CIMV2"
Get-WmiObject -Class Win32_USBControllerDevice -ComputerName $computer -Namespace $namespace |
ForEach-Object { [wmi]($_.Dependent) } |
Sort-Object Manufacturer,Description,DeviceID |
Format-Table -GroupBy Manufacturer Description,Service,DeviceID |
Out-File -Append -FilePath C:\USB\usblist.txt
The idea is to query the USB controller-device relationship on each remote computer, resolve the Dependent property to a real WMI instance, and then write the sorted information to a text file . If the file is empty, you need to check permissions, remote accessibility, the firewall, and, of course, the script syntax (misaligned spaces or improperly closed quotation marks are a classic culprit).
With a good structure of this type of script, you can achieve a consolidated inventory of USB devices per computer , grouped by manufacturer and description, without depending on external software.
Using USB ID to find and maintain drivers
Beyond the security aspect, knowing and handling Hardware IDs is key to finding suitable drivers , especially when Windows fails to find the generic one or after a system update that leaves a device "dead".
Hierarchical pattern: IDs of this type usually follow a hierarchical pattern, especially on PCI/PCIe devices:
- VEN_XXXX Identify the chip manufacturer.
- DEV_XXXX Indicate the specific model of the device.
- SUBSYS_XXXXXXXXX details assembler variants, region, etc.
For USB, we find strings like USB\VID_XXXX&PID_YYYY and sometimes the serial number. When a device stops working after a Windows update, copying the exact HWID and entering it into the manufacturer's search engine or specialized databases is a very accurate way to find the correct driver, even for older hardware.
Tools like Snappy Driver Installer Origin or commercial driver management solutions often rely on these identifiers to accurately match devices with drivers . There are also local search engines that can sift through hundreds of .inf files using the embedded HWIDs, which is incredibly useful when you have a library of downloaded drivers but can't remember which one corresponds to what.
A useful trick for the organized among us is to maintain a spreadsheet with columns for VEN, DEV, SUBSYS, description, and driver path . Using functions like MID() in Excel, you can automatically extract these fields from the HWID string, which ultimately saves you many hours of trial and error when dealing with poorly documented hardware.
Complementary tools for working with USB IDs
Although the focus here is on what you can do with PowerShell and built-in Windows utilities , it's worth knowing about some auxiliary tools—especially if your environment allows their installation—that make working with USB devices easier.
USB Device Viewer (USBView) from Microsoft
Microsoft offers the USB Device Viewer (USBView) utility free of charge , included in the Windows Driver Kit. It provides a tree view of all USB controllers and devices present on the system, and clearly displays the idVendor, idProduct, and other device descriptor fields .
Steps: The basic steps are:
- Install the corresponding Windows Driver Kit package and locate USBView.exe (usually in the debuggers path, for example, Debuggers\x64).
- Run it and select the USB device in the tree on the left.
- Check the fields in the right panel idVendor and idProduct, along with the rest of the descriptor.
If you are developing drivers, for example with VISA Driver Development Wizard , this data is essential to tell the driver which devices to handle based on their VID and PID.
Online USB ID databases
When you don't have the device physically on hand but know its name or part of its identifier, you can also use public USB ID databases . On these sites, you can search by model, brand, or even by fragments of the VID/PID, and they will return the official Vendor ID and Product ID values registered for that device.
This is especially useful when you have a partial HWID, or Windows only gives a generic description , and you need to confirm which VID/PID corresponds to it before searching for a compatible driver or applying a device blocking policy by ID.
Ultimately, mastering USB IDs and other hardware identifiers turns you into a kind of "system detective": you can trace which device caused a crash, which USB drive was connected to which computer and when, or why a driver stopped loading after an update . With PowerShell as your core tool, combined with Device Manager, WMI, a specialized utility, and, if necessary, a small Flask server, you have everything you need to monitor and control your environment's USB ecosystem without relying on cumbersome third-party solutions or unreliable assumptions.
Table of Contents
- 1 What is a Hardware ID (HWID) and why should you care?
- 2 How to build a USB device identifier
- 3 View the USB Hardware ID using Windows graphical tools
- 4 Obtain the USB hardware ID from PowerShell
- 5 Automatically monitor and log USB devices with PowerShell
- 6 Create a simple REST API to log USB data
- 7 Schedule USB scripts to run at Windows startup
- 8 Track USB devices on remote computers using PowerShell
- 9 Using USB ID to find and maintain drivers
- 10 Complementary tools for working with USB IDs