2 Methods to Get Available Serial Ports on Windows

2 Methods to Get Available Serial Ports on Windows

Serial ports have been a fundamental part of computing for decades, providing a way to communicate with various external devices, such as printers, GPS receivers, microcontrollers, and more. Whether you're a seasoned developer or a hobbyist, knowing how to retrieve a list of available serial ports on a Windows system is a crucial skill. This information can help for troubleshooting communication issues. This tutorial provides 2 methods how to get available serial ports on Windows.

Method 1 - CMD

Use wmic command to query Win32_SerialPort class for retrieving serial ports available on a Windows system.

wmic path Win32_SerialPort get Name | find /v "Name"

The command prints Name property of each serial port. For example:

Communications Port (COM1)
Communications Port (COM2)

Method 2 - PowerShell

In PowerShell window, use the Get-CimInstance cmdlet to query information from the Win32_SerialPort class and then extract the Name property from the resulting objects.

(Get-CimInstance Win32_SerialPort).Name

Leave a Comment

Cancel reply

Your email address will not be published.