Detecting drive letter for an USB Stick

So first you run example and do a query like this one:
select PNPDeviceID, DeviceID, Model from Win32_DiskDrive where InterfaceType='USB'This queries for PNPDeviceID, DeviceID and Model properties in Win32_DiskDrive array where interface is USB. This gives you a couple of USB Devices with disks:

Using the PNP Device ID and Model, you should be able to identify your stick. Also with DeviceID you get link to partition list. So we run next query to find associated partition for this device ID:
Associators of {Win32_DiskDrive.DeviceID='\\.\PHYSICALDRIVE1'} where AssocClass=Win32_DiskDriveToDiskPartitionPLease replace the device ID value in this string with the one you got above.

Now we query again with the new Device ID for the matching logical disk:
Associators of {Win32_DiskPartition.DeviceID='Disk #1, Partition #0'} where AssocClass=Win32_LogicalDiskToPartitionThis gives us now the DeviceID with "E:". This is the drive letter of the pen drive I used:

And that's it. If you have multiple devices, you may need to query several times. All the code to query and get values is in the example.
