Skip to content

Instantly share code, notes, and snippets.

@winkler-winsen
Last active February 17, 2025 15:32
Show Gist options
  • Save winkler-winsen/c7b4ccede0ca777fbb58aca8f6431e70 to your computer and use it in GitHub Desktop.
Save winkler-winsen/c7b4ccede0ca777fbb58aca8f6431e70 to your computer and use it in GitHub Desktop.
Reset Windows COM port settings and remove hidden / non active devices
# Reset Windows COM port settings
# 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter' ComDB
$path='HKLM:\SYSTEM\CurrentControlSet\Control\COM Name Arbiter'
Set-ItemProperty -Path $path -Name Test -Value ([byte[]](0x01)) -Verbose
# 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports'
$path='HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports'
Get-ItemProperty $path | Get-Member -MemberType NoteProperty | where Name -like 'COM*' | foreach { Remove-ItemProperty -Path $path -Name $_.Name -Verbose }
# remove PnP devices "Name (COM*)"
Get-PnpDevice | Where -FilterScript { $_.Class -EQ 'Ports' -and $_.FriendlyName -match '(COM[\d.])' } | % { & "pnputil.exe" /remove-device $_.InstanceId }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment