几天前我问了这个问题, How to connect and remove bluetooth in windows powerhell,但是每当我尝试运行代码时:
$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
我收到此错误:
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
我以提升的权限运行它,并且没有错误代码enable-pnpdevice
,只有 disable-pnpdevice 有问题。
有谁知道如何做到这一点?在保罗发表评论后,我仔细检查了我是否在管理员中,我不是,但是当我这样做时,现在弹出:
Disable-PnpDevice : 不支持在 line:2 char:1 + Disable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false + ~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotImplemented: (Win32_PnPEntity ...B17A1&0&FAD...):ROOT\cimv2\Win32_PnPEntity) [禁用-PnpDevice],CimException + FullyQualifiedErrorId:HRESULT 0x8004100c,禁用-PnpDevice
另外,我跑了
$device
Status Class FriendlyName InstanceId
------ ----- ------------ ----------
OK Bluetooth MX Master 2S BTHLE\DEV_FA...
不确定这是否是保罗所说的包含的意思。
过了一会儿,在 Paul 帮助我聊天时,我们确定我的蓝牙芯片或实际软件有问题,所以如果有人对此有任何想法,将不胜感激。