I want to incorporate a dropdown menu that is populated with the list of available COM ports. I can't find any way to easily get the names of the available COM ports to put in the place of COM4 that creates the $port.
$port = new-Object System.IO.Ports.SerialPort COM4,19200,None,8,one
By using Win32_SerialPort I am able to easily extract COM1 and COM3.
Get-WmiObject Win32_SerialPort | Select-Object deviceid
Results:
deviceid
COM3
COM1
But my device manager shows 16 available ports from a remote serial hub. Device Manager Snapshot
Here is what I have tried and I am able to narrow down the Name, but can't figure out how to extract just the (COM--) part.
Get-WmiObject Win32_pnpentity -Filter "Name LIKE 'devicemaster port%'" | Select-Object -Property Name