Powershell Script to set COM Port for USB Serial Port
1 min readThere was a requirement at my company that a particular USB Serial device use the same COM Port every time it is plugged in. Below is a script to accomplish that. I selected COM 7 to avoid conflicts. In your case navigate to the registry to find the right values to enter for $DeviceHardwareID and $DeviceInstance. It should match the path in the registry
$DeviceHardwareID = "VID_0403+PID_6001+AR0JI7QAA"
$DeviceInstance = "0000"
$ComPort = "COM7"
$RegistryPath = "HKLM:\SYSTEM\CurrentControlSet\Enum\FTDIBUS\$DeviceHardwareID\$DeviceInstance\Device Parameters"
$PropertyName = "PortName"
$PropertyType = "String"
if (Test-Path -Path $RegistryPath) {
Set-ItemProperty -Path $RegistryPath -Name $PropertyName -Value $ComPort -Type $PropertyType
Write-Host "PortName set to $ComPort"
} else {
Write-Host "Registry path not found. Please check the device hardware ID and instance."
}