Any/all commands to get attached USB data?

I’m still trying to solve the nagging problem of attaching/unattaching USBs with script solutions.

The big problem is the USB Id changes depending on the other attached devices.

I’m looking for some kind of solution that will allow me to pattern match against a USB device name, and then extract out the ID, then auto attach.

What are any/all the commands that might give me the complete list of USB devices and their current associated IDs?

(Ideally commands that can be run from dom0.)

Perhaps this is relevant to link:

I couldn’t get that to work on my machine.