I won't go into details because my English is too bad. But I try to assign COM3 port to a specific device.
First thing I tried to do is automatically assign port number based on device name.
But it doesn't work.
I wanted something like this (roughly):
When a new device is connected :
If (device.service = silabser or device.name="My device"){
portCOM = COM3 #reattribute COM port
}
So i tried a script that collect the current port number from my device to reattribute it on the COM3. Then my users can run the script to configure the device easily.
$adaptateur = Get-WmiObject -Class Win32_SerialPort | Where-Object {$_.Name -like "*My device*"}
$element = $adaptateur.DeviceID
change port $element=COM3
$adaptateur.Disable() #I know this doesn't work
$adaptateur.Enable() #I know this doesn't work
But... I get an "error code = 0x2" with "change port" command and I can't reboot the device...
So nothing is working.
I suck in Powershell...
Sorry for my english :p