Last active
February 17, 2025 15:32
-
-
Save winkler-winsen/c7b4ccede0ca777fbb58aca8f6431e70 to your computer and use it in GitHub Desktop.
Reset Windows COM port settings and remove hidden / non active devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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