- 02 Feb 2024
- 1 Minute to read
- Print
- PDF
Turn Bluetooth status On/Off on Windows devices
- Updated on 02 Feb 2024
- 1 Minute to read
- Print
- PDF
The following PowerShell script helps the IT Admins to remotely turn On/Off the Bluetooth state on multiple managed Windows devices.
Create a file on your desktop, for example, turn_on_off_bluetooth.ps1 and open it in a text editor like notepad++
Copy the contents below to the file or click here to download the file.
Set the $BluetoothStatus variable to "On" or "Off" based on your desired Bluetooth status.
$BluetoothStatus = "Off" # Set this variable to "On" or "Off" based on your desired Bluetooth status If ((Get-Service bthserv).Status -eq 'Stopped') { Start-Service bthserv } Add-Type -AssemblyName System.Runtime.WindowsRuntime $asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0] Function Await($WinRtTask, $ResultType) { $asTask = $asTaskGeneric.MakeGenericMethod($ResultType) $netTask = $asTask.Invoke($null, @($WinRtTask)) $netTask.Wait(-1) | Out-Null $netTask.Result } [Windows.Devices.Radios.Radio,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null [Windows.Devices.Radios.RadioAccessStatus,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null Await ([Windows.Devices.Radios.Radio]::RequestAccessAsync()) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null $radios = Await ([Windows.Devices.Radios.Radio]::GetRadiosAsync()) ([System.Collections.Generic.IReadOnlyList[Windows.Devices.Radios.Radio]]) $bluetooth = $radios | ? { $_.Kind -eq 'Bluetooth' } [Windows.Devices.Radios.RadioState,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null Await ($bluetooth.SetStateAsync($BluetoothStatus)) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null
Follow our guide to upload & publish the PowerShell script using Scalefusion Dashboard.
Please note that to use the PowerShell scripts, the Scalefusion MDM Agent Application must be installed on the device(s). Please follow our guide to publish and install the Scalefusion MDM Agent Application.
Notes:
The scripts and their contents are sourced from various albeit authenticated Microsoft sources and forums.
Please validate the scripts on a test machine before deploying them on all your managed devices.
Scalefusion has tested these scripts, however, Scalefusion will not be responsible for any loss of data or system malfunction that may arise due to the incorrect usage of these scripts.