Windows 11의 모던스탠바이 모드 진입 시 블루투스를 Off 하는 방법.
Off 하는 이유는 모던스탠바디 절전 모드 진입 후 블루투스 마우스에 의해 절전이 해제되는 것을 방지하기 위함이다.
1. 스크립트 작성
아래 코드를 적당한 폴더에 bluetooth.ps1 라는 이름으로 저장 (여기서는 C:\work 폴더에 저장)
[CmdletBinding()] Param (
[Parameter(Mandatory=$true)][ValidateSet('Off', 'On')][string]$BluetoothStatus
)
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
위 스크립트를 수동으로 실행하면,
bluetooth off :
> powershell -ExecutionPolicy Unrestricted -WindowStyle Hidden -File "C:\work\bluetooth.ps1" off
-> 실행하면 장치관리자의 Bluetooth 탭의 장치들이 사라지는 것을 볼 수 있다.
bluetooth on :
> powershell -ExecutionPolicy Unrestricted -WindowStyle Hidden -File "C:\work\bluetooth.ps1" on
-> 실행하면 장치관리자의 Bluetooth 탭의 장치들이 다시 나타난다.
2. Windows 스케줄링 - 1 (절전모드 진입 시 bluetooth off)
Windows 시작 버튼 - '작업 스케줄러' 로 검색하여 스케줄러 띄우기
동작 - 작업 만들기 -



인수 추가(옵션)(A):
-ExecutionPolicy Unrestricted -WindowStyle Hidden -File "C:\work\bluetooth.ps1" off
3. Windows 스케줄링 - 2 (절전모드에서 깨어날 때 bluetooth on)



인수 추가(옵션)(A):
-ExecutionPolicy Unrestricted -WindowStyle Hidden -File "C:\work\bluetooth.ps1" on
