I asked this question a few days ago, How to connect and remove bluetooth in windows powerhell, but whenever I try running the code:
$device = Get-PnpDevice | Where-Object {$_.Class -eq "Bluetooth" -and $_.FriendlyName -eq "MX Master 2S"}
Disable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false
Start-Sleep -Seconds 10
Enable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false
I get this error:
Disable-PnpDevice : Generic failure At C:\Users\wadeb\OneDrive\Desktop\Mouse Bluetooth Reset.ps1:2 char:1 + Disable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (Win32_PnPEntity...B17A1&0&FAD...):ROOT\cimv2\Win32_PnPEntity) [ Disable-PnpDevice], CimException + FullyQualifiedErrorId : HRESULT 0x80041001,Disable-PnpDevice
I am running it with elevated permissions, and there is no error code with enable-pnpdevice
, there are only problems with disable-pnpdevice.
Does anyone know how to do this? after paul's comment, I double checked if I was in administrator, I wasn't, but when I did, this now pops up:
Disable-PnpDevice : Not supported At line:2 char:1 + Disable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotImplemented: (Win32_PnPEntity...B17A1&0&FAD...):ROOT\cimv2\Win32_PnPEntity) [Disable-PnpDevice], CimException + FullyQualifiedErrorId : HRESULT 0x8004100c,Disable-PnpDevice
also, I ran
$device
Status Class FriendlyName InstanceId
------ ----- ------------ ----------
OK Bluetooth MX Master 2S BTHLE\DEV_FA...
Not sure if that is what paul meant by contained though.
After a while, with Paul helping me in the chat, we determined that there was a problem with my Bluetooth chip, or the actual software, so if anyone has any ideas about that, that would be greatly appreciated.
I just experienced the exact same problem and couldn't find a solution online. However, I discovered (by trial and error) that the issue was that the PowerShell script and/or command prompt must be started with "Run As Administrator" privileges. Once I did that, I was able to run the command just fine.
It would be nice if the error message was clear enough to point to that specific issue, but hopefully this will help someone else looking for the solution.