Category filter

Script to show a list of connected Bluetooth devices on Windows 10/11

Bluetooth devices enable wireless communication with other compatible devices via Bluetooth technology. They seamlessly connect to devices through the built-in Bluetooth functionality.

With the use of Hexnode’s Execute Custom Script action, IT administrators will be able to run the script given below to show connected Bluetooth devices to Windows endpoints managed in your workplace environment. This aids IT administrators in monitoring unauthorized Bluetooth connections, allowing them to take necessary actions to mitigate potential network risks that could harm the company’s network.

Disclaimer:

The sample scripts provided below are adapted from third-party open-source sites.

PowerShell script to show all Bluetooth devices currently connected

The PowerShell script provided fetches and lists the names of connected Bluetooth devices on a Windows system. It uses the Get-WmiObject cmdlet in PowerShell to access information from the Windows Management Instrumentation (WMI) repository. The cmdlet fetches instances of WMI classes or information about the available WMI classes. The command targets the Win32_PnPEntity class in WMI which represents the Plug and Play devices on the Windows system. By querying this class, it selectively captures information about devices categorized as ‘Bluetooth’. This data is stored in the $bluetoothDevices variable for further processing. Subsequently, a foreach loop iterates through the devices, displaying their names using the Write-Host command.

Batch script to show all Bluetooth devices currently connected

This batch script is designed to identify and list connected Bluetooth devices on a Windows system. It utilizes the wmic command to query the Win32_PnPEntity class, filtering the devices categorized as ‘Bluetooth’, and retrieves their names in list format. The output is then filtered using findstr to include only lines starting with ‘Name=’. Within a loop, each line is processed to extract the device name, which is displayed with a prefix indicating that it is a Bluetooth device.

What happens at the device end?

After the execution of the script, a list of all connected Bluetooth devices can be seen from the Action History of the Windows device in the Hexnode portal. If the Windows device’s Bluetooth is either disabled or no Bluetooth devices are connected, the script will list Bluetooth adapters or modules integrated into the computer’s hardware. These components facilitate wireless communication between Windows devices and other Bluetooth-enabled devices.

A list of all connected Bluetooth devices will be shown in the Action History of the Windows 10/11 device

Notes:

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository