Skip to content

Instantly share code, notes, and snippets.

@Chirishman
Last active September 26, 2018 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chirishman/fafafe6c034010dd9173f45b6a5e5bd7 to your computer and use it in GitHub Desktop.
Save Chirishman/fafafe6c034010dd9173f45b6a5e5bd7 to your computer and use it in GitHub Desktop.
$AllSerial = [System.IO.Ports.SerialPort]::getportnames()
$RemoveNonUSBSerial = Get-PnpDevice -FriendlyName '* (COM*' -Class 'Ports' | ?{$_.DeviceID -notmatch '^BTHENUM'}
$FriendlyNames = ($RemoveNonUSBSerial.FriendlyName) -join '|'
$USBComPorts = $AllSerial | ?{$FriendlyNames -match "\($_\)"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment