Powershell – Show all available Serial COM ports

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

2 thoughts on “Powershell – Show all available Serial COM ports”

Leave a Reply

Your email address will not be published. Required fields are marked *