2

How can I find the value of "is connected" for a Bluetooth device? I've tried Get-WMIObject cmdlets and a few others but none of the values changed when I connect/disconnect. The only place I have found the value to change is in the attached image. I found it in the Device Properties for the Bluetooth Headset I am trying to use.

I'm trying to write a toggle script for AutoHotKey to send btcom commands, but I would like to write an if statement with that. The piece I'm missing here is finding the value of "is connected" on my Bluetooth device.

Example of output from Get-WMIObject:

PS H:\> Get-WmiObject -Query "select * from win32_PnPEntity where Caption='Jordan's AirPods Pro'"


__GENUS                     : 2
__CLASS                     : Win32_PnPEntity
__SUPERCLASS                : CIM_LogicalDevice
__DYNASTY                   : CIM_ManagedSystemElement
__RELPATH                   : Win32_PnPEntity.DeviceID="BTHENUM\\DEV_14C88BC438FE\\7&2D1C6A81&0&BLUETOOTHDEVICE_14C88BC438FE"
__PROPERTY_COUNT            : 26
__DERIVATION                : {CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER                    : OL-2TK93103QK
__NAMESPACE                 : root\cimv2
__PATH                      : \\OL-2TK93103QK\root\cimv2:Win32_PnPEntity.DeviceID="BTHENUM\\DEV_14C88BC438FE\\7&2D1C6A81&0&BLUETOOTHDEVICE_14C88BC438FE"
Availability                :
Caption                     : Jordan’s AirPods Pro
ClassGuid                   : {e0cbf06c-cd8b-4647-bb8a-263b43f0f974}
CompatibleID                : {BTHENUM\GENERIC_DEVICE}
ConfigManagerErrorCode      : 0
ConfigManagerUserConfig     : False
CreationClassName           : Win32_PnPEntity
Description                 : Bluetooth Device
DeviceID                    : BTHENUM\DEV_14C88BC438FE\7&2D1C6A81&0&BLUETOOTHDEVICE_14C88BC438FE
ErrorCleared                :
ErrorDescription            :
HardwareID                  : {BTHENUM\Dev_14C88BC438FE}
InstallDate                 :
LastErrorCode               :
Manufacturer                : Microsoft
Name                        : Jordan’s AirPods Pro
PNPClass                    : Bluetooth
PNPDeviceID                 : BTHENUM\DEV_14C88BC438FE\7&2D1C6A81&0&BLUETOOTHDEVICE_14C88BC438FE
PowerManagementCapabilities :
PowerManagementSupported    :
Present                     : True
Service                     :
Status                      : OK
StatusInfo                  :
SystemCreationClassName     : Win32_ComputerSystem
SystemName                  : OL-2TK93103QK
PSComputerName              : OL-2TK93103QK



PS H:\>
jenglish
  • 21
  • 1
  • 7
  • Welcome to SO. I think you're close. On my laptop, I have my Bluetooth enabled stereo (named STR514) paired to my Bluetooth network adapter. When connected, the Status shows 'OK'. When it's not connected, the status shows 'Unknown'. The stereo is listed as an `AudioEndpoint` and shows-up as `Headphones`. Here's how I'm checking the Status: `Get-PnPDevice | Where-Object -FilterScript { $_.Class -eq 'AudioEndpoint' -and $_.FriendlyName -like '*STR514*' }` Note: The 'Status' change is not immediate, and sometimes takes over a minute to update. – leeharvey1 Jul 28 '20 at 16:42
  • I guess the answer is here: https://stackoverflow.com/questions/71607722/how-to-know-if-a-bluetooth-device-is-connected-or-disconnected-by-powershell – JinSnow Nov 14 '22 at 11:52

0 Answers0