Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Last active October 21, 2016 22:18
Show Gist options
  • Save matthewjberger/8bec7d3689afaa1501d995dcc1f22f49 to your computer and use it in GitHub Desktop.
Save matthewjberger/8bec7d3689afaa1501d995dcc1f22f49 to your computer and use it in GitHub Desktop.
This will generate an html table that lists available COM ports on windows. It can be styled with css.
# Multi-Line
$style = @"
<style type="text/css">
th {
background: lightblue
}
tr {
text-align:left
}
table, th, td{
border: 1px solid black;
}
</style>
"@
Get-WMIObject Win32_SerialPort | `
Select-Object DeviceID,Name,Description | `
Sort-Object DeviceID | `
ConvertTo-HTML -Head $style
# One Line
Get-WMIObject Win32_SerialPort | Select-Object DeviceID,Name,Description | Sort-Object DeviceID | ConvertTo-HTML -Head $style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment