bluetooth
Created: 2025-06-07 03:54:06 | Last updated: 2025-06-07 03:54:06 | Status: Public
Method 1: Standard removal (try first)
function Remove-AllBluetoothDevices {
Write-Host “Removing all Bluetooth devices…” -ForegroundColor Yellow
# Get all Bluetooth devices
$btDevices = Get-PnpDevice | Where-Object {
$_.Class -eq "Bluetooth" -or
$_.FriendlyName -like "*Bluetooth*" -or
$_.InstanceId -like "*BTHUSB*" -or
$_.InstanceId -like "*BTHLE*"
}
foreach ($device in $btDevices) {
try {
Write-Host "Removing: $($device.FriendlyName)" -ForegroundColor Cyan
$device | Disable-PnpDevice -Confirm:$false
$device | Remove-PnpDevice -Confirm:$false
}
catch {
Write-Warning "Failed to remove $($device.FriendlyName): $($_.Exception.Message)"
}
}
}
Method 2: Registry nuclear option (use if Method 1 fails)
function Remove-BluetoothDevicesRegistry {
Write-Host “Nuclear option: Clearing Bluetooth registry…” -ForegroundColor Red
# Stop Bluetooth services first
$services = @("bthserv", "BthAvctpSvc", "BTHPORT")
foreach ($service in $services) {
try {
Stop-Service -Name $service -Force -ErrorAction SilentlyContinue
Write-Host "Stopped service: $service" -ForegroundColor Green
}
catch {
Write-Warning "Could not stop service: $service"
}
}
# Clear paired devices from registry
$regPaths = @(
"HKLM:\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Devices",
"HKLM:\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys",
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Bluetooth\ExceptionDB"
)
foreach ($path in $regPaths) {
if (Test-Path $path) {
try {
Remove-Item -Path $path -Recurse -Force
Write-Host "Cleared registry path: $path" -ForegroundColor Green
}
catch {
Write-Warning "Could not clear: $path"
}
}
}
# Restart services
foreach ($service in $services) {
try {
Start-Service -Name $service -ErrorAction SilentlyContinue
Write-Host "Restarted service: $service" -ForegroundColor Green
}
catch {
Write-Warning "Could not restart service: $service"
}
}
}
Method 3: Device Manager approach (most thorough)
function Remove-BluetoothDevicesDevMgmt {
Write-Host “Using Device Manager approach…” -ForegroundColor Magenta
# Get all devices with Bluetooth-related hardware IDs
$allDevices = Get-CimInstance -ClassName Win32_PnPEntity | Where-Object {
$_.DeviceID -like "*BTHUSB*" -or
$_.DeviceID -like "*BTHLE*" -or
$_.DeviceID -like "*BTHENUM*" -or
$_.Name -like "*Bluetooth*" -or
$_.Description -like "*Bluetooth*"
}
foreach ($device in $allDevices) {
try {
Write-Host "Force removing: $($device.Name)" -ForegroundColor Yellow
# Try to disable first
$pnpDevice = Get-PnpDevice -InstanceId $device.DeviceID -ErrorAction SilentlyContinue
if ($pnpDevice) {
$pnpDevice | Disable-PnpDevice -Confirm:$false -ErrorAction SilentlyContinue
Start-Sleep -Milliseconds 500
$pnpDevice | Remove-PnpDevice -Confirm:$false -ErrorAction SilentlyContinue
}
# If that fails, try WMI removal
$device.Delete()
Write-Host "Successfully removed: $($device.Name)" -ForegroundColor Green
}
catch {
Write-Warning "Failed to remove $($device.Name): $($_.Exception.Message)"
}
}
}
Method 4: PowerShell + DevCon hybrid (if you have Windows SDK)
function Remove-BluetoothDevicesDevCon {
$devconPath = “${env:ProgramFiles(x86)}\Windows Kits\10\Tools\x64\devcon.exe”
if (Test-Path $devconPath) {
Write-Host "Using DevCon for forced removal..." -ForegroundColor Blue
# Remove all Bluetooth devices
& $devconPath remove "*BTHUSB*"
& $devconPath remove "*BTHLE*"
& $devconPath remove "*BTHENUM*"
# Rescan hardware
& $devconPath rescan
}
else {
Write-Warning "DevCon not found. Install Windows SDK or use other methods."
}
}
Main execution function
function Force-RemoveAllBluetoothDevices {
param(
[switch]$Nuclear,
[switch]$DevMgmt,
[switch]$DevCon
)
Write-Host "=== Bluetooth Device Force Removal ===" -ForegroundColor White -BackgroundColor Blue
# Check if running as admin
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Error "This script requires Administrator privileges. Run PowerShell as Administrator."
return
}
if ($Nuclear) {
Remove-BluetoothDevicesRegistry
}
elseif ($DevMgmt) {
Remove-BluetoothDevicesDevMgmt
}
elseif ($DevCon) {
Remove-BluetoothDevicesDevCon
}
else {
# Standard approach
Remove-AllBluetoothDevices
}
Write-Host "`nOperation complete. You may need to restart your computer." -ForegroundColor Green
Write-Host "To re-enable Bluetooth, go to Device Manager and scan for hardware changes." -ForegroundColor Cyan
}