如何在 Windows PowerShell 中连接蓝牙或音频设备?

问题描述 投票:0回答:0

我正在尝试自动连接 AirPods,这样我就不必每次登录计算机参加会议时都手动执行此操作。 Windows 会记住我的 AirPods,因为它们之前已配对。我不需要自动化配对,但我想自动化以下操作(写出实际名称):

  1. 单击此处连接。

  1. 在此处选择音频设备:

从我最初的搜索中,我发现了这篇文章:

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

我正在以管理员身份运行 powershell。起初,我按原样尝试了上述帖子中的步骤(过滤蓝牙——我通过调用 Get-PnpDevice 找到了友好名称,后面什么都没有,然后只是阅读列表),但我在使用它后意识到并且没有看到任何东西,它实际上返回了两个设备 - 大概每个耳机一个:

$device = Get-PnpDevice -class Bluetooth -friendlyname "AirPods Pro Avrcp Transport"
Enable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false


PS C:\WINDOWS\system32> $device

返回以下内容:

没关系,因为MSDN文档说可以为InstanceId输入一个字符串[],但最终在这些蓝牙设备Id上运行Enable对我没有任何作用。然后我意识到,设备在上图中显示为音频,并运行以下命令:

$device = Get-PnpDevice -class AudioEndpoint -friendlyname "Headphones (AirPods Pro Stereo)"
Enable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false

返回以下内容:

我不知道如何理解错误消息:

类别信息:未指定:(Win32_PnPEntity...}.{EB5535DA...):ROO

windows powershell automation admin
© www.soinside.com 2019 - 2024. All rights reserved.