Public/Radio/Get-RadioState.ps1
|
Function Get-RadioState { <# .SYNOPSIS Retrieves all available radio adapters (WiFi, Bluetooth, Mobile) and displays their current status. .DESCRIPTION This function uses the Windows Runtime (WinRT) API to access the system's radio hardware directly. The result is a list of Radio objects that can be piped directly into Set-RadioState. .EXAMPLE Get-RadioState Displays all radios and whether they are 'On' or 'Off'. .EXAMPLE Get-RadioState | Where-Object Kind -eq 'WiFi' | Set-RadioState -SetState Off Specifically searches for the WiFi radio and turns it off. .OUTPUTS Windows.Devices.Radios.Radio #> [outputType([Windows.Devices.Radios.Radio])] param( [int]$TimeoutMS = 10000 ) Process { $accessStatus = Await ([Windows.Devices.Radios.Radio]::RequestAccessAsync()) ([Windows.Devices.Radios.RadioAccessStatus]) if ($accessStatus -eq "Allowed") { Await -WinRtTask ([Windows.Devices.Radios.Radio]::GetRadiosAsync()) -ResultType ([System.Collections.Generic.IReadOnlyList[Windows.Devices.Radios.Radio]]) -TimeoutMs $TimeoutMS } else { Write-Warning "No Access to radio hardware Status: $accessStatus" } } } |