I'm automating a script to control the number of COM/LPT ports that the peripheral device will work on by changing the “PortName” and “FriendlyName” records in the registry hierarchy of the peripheral device connected to the computer.
In the Windows registry of a machine, we have the registry structure for a peripheral connected to a computer's USB interface: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB<hardware id><instance id>
On a Windows 11 machine when connecting to a certain USB port the registry path is: Computador\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_1CBE&PID_0002&MI_00\ 6&3D0ED8B&0&0000
The problem is the “instance id” is changed depending on:
- The computer (with the same Windows 11 operating system)
- The the chosen USB port.
In my powershell script I am creating the directory structure in the windows registry, to later change the “PortName” and the “FriendlyName”. So I would like to know if there is a way to determine, for each Windows machine and available USB port, which is the “instance id ” that will be created (before connecting the peripheral device to the computer)?