Here are some methods to list all your available COM ports. It’s handy when you’re swapping USB to serial adapters! Here’s a cmd batch version if you prefer: Batch – Show all available COM ports
Three different ways…
One:
(Get-WmiObject -query "SELECT * FROM Win32_PnPEntity" | Where {$_.Name -Match "COM\d+"}).name
Output:
Prolific USB-to-Serial Comm Port (COM4) Prolific USB-to-Serial Comm Port (COM6)
Two:
change port /query
Output:
COM4 = \Device\ProlificSerial0 COM6 = \Device\ProlificSerial2
Three:
$COMportList = [System.IO.Ports.SerialPort]::getportnames() ForEach ($COMport in $COMportList) { $temp = new-object System.IO.Ports.SerialPort $COMport echo $temp.PortName $temp.Dispose() }
Output:
COM4 COM6
Very valuable info , Thanks
Glad to help! 🙂
Thanks man!
You’re welcome my dude.