2

I'm trying to automate connecting my AirPods so I don't have to manually do it each time I log on to my machine for a meeting. Windows remembers my AirPods since they were previously paired. I don't need to automate the pairing, but I'd like to automate the following (scribbling out actual names):

  1. Clicking connect here.

Windows Bluetooth & other devices

  1. Selecting the audio device here:

Selecting Audio Output Device

From my initial searching, I found this post:

How to connect and disconnect a Bluetooth device with a PowerShell script on Windows?

I am running powershell as Admin. At first, I attempted the steps in the aforementioned post as-is (which filters for Bluetooth -- I found friendlyname by calling Get-PnpDevice with nothing after it, and just reading through the list), but I realized after playing with it and not seeing anything, that it's actually returning two devices - presumably one for each headphone:

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


PS C:\WINDOWS\system32> $device

returns the following:

Return from Enable-PnpDevice

That's okay because the MSDN documentation says one can input a string[] for InstanceId, but ultimately running Enable on these bluetooth devices Ids did nothing for me. So then I realized, the device shows up as Audio in the image above, and ran the following:

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

Which returns the following:

PowerShell Error Message

I don't know what to make of the error messages:

CategoryInfo: NotSpecified: (Win32_PnPEntity...}.{EB5535DA...):ROOT\cimv2\Win32_PnPEntity)[Enable-PnpDevice], CimException
FullyQualifiedErrorId : HRESULT 0x80041001,Enable-PnpDevice

I'm out of ideas and can't find anything from searching. Any ideas or info?

EDIT: I have found that if I manually do step 1. above, the error message goes away, but I don't really see a change in Windows (so similar behavior to running the Bluetooth InstanceIds)

hallibut
  • 136
  • 1
  • 12

0 Answers0