小编All*_*497的帖子

如何在 Windows 上使用 PowerShell 脚本连接和断开蓝牙设备?

我有一台非常慢且相对便宜的计算机。当我打开它时,我打开了我的蓝牙鼠标。鼠标正常工作几秒钟,然后连接断开。如果我然后重新连接鼠标,它会正常工作,直到我再次将其关闭。

我的目标是:我想编写一个 PowerShell 脚本来自动重新连接鼠标,但我不知道它在 PowerShell 中如何与蓝牙配合使用。有人可以帮我吗?

windows powershell bluetooth

7
推荐指数
2
解决办法
1万
查看次数

Powershell 不允许我对蓝牙设备使用 disable-pnpdevice

几天前我问了这个问题, 如何在 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
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

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
Run Code Online (Sandbox Code Playgroud)

我正在使用提升的权限运行它,并且没有错误代码enable-pnpdevice,只有 disable-pnpdevice 有问题。

有谁知道如何做到这一点?在 paul 发表评论后,我再次检查我是否是管理员,我不是,但是当我这样做时,现在会弹出:

Disable-PnpDevice : 不支持 At line:2 char:1 + Disable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false …

powershell bluetooth plug-and-play

3
推荐指数
1
解决办法
5110
查看次数

标签 统计

bluetooth ×2

powershell ×2

plug-and-play ×1

windows ×1