How to turn on or off Wi-Fi Software radio status with PowerShell

Any help how can I turn on/off the software radio status on Windows 11? This is the status of my Wi-Fi:

Netsh WLAN show interfaces

There is 1 interface on the system:

    Name                   : Wi-Fi
    Description            : Killer Wireless-n/a/ac Wireless Network Adapter
    GUID                   : xx
    Physical address       : xx
    Interface type         : Primary
    State                  : disconnected
    Radio status           : Hardware On
                             Software Off

    Hosted network status  : Not available

This is the setting in Windows 11: enter image description here

I've tried the commands Enable-NetAdapter and Disable-NetAdapter, but those commands are for specific network interfaces, not for disabling of enabled WiFi broadly speaking.

Other users have suggested this command, however this does not enable or disable WiFi in software mode:

netsh interface set interface name="Wi-Fi" admin=DISABLED

Solution 1:

Solution is the same as proposed by @Diskoteket:

# Set-NetAdapterRadioPowerState.ps1
# credit to ben-n on superuser; adapted from https://superuser.com/a/1293303

[CmdletBinding()] Param (
    [Parameter(Mandatory=$true)][ValidateSet('Off', 'On')][string]$WifiStatus
)

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]])
$wifi = $radios | ? { $_.Kind -eq 'WiFi' }
[Windows.Devices.Radios.RadioState,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
Await ($wifi.SetStateAsync($WifiStatus)) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null

Then run it from powershell 5 (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe), in my system version 5.1.22000.282.

Don't use powershell 7 (latest version now 7.2.1, location C:\Program Files\PowerShell\7\pwsh.exe) because doesn't work.

Result now after activation (not connected to any wifi because it's connected by RJ45 which is priority):

.\Set-NetAdapterRadioPowerState.ps1 -WifiStatus On
Netsh WLAN show interfaces

There is 1 interface on the system:

    Name                   : Wi-Fi
    Description            : Killer Wireless-n/a/ac Wireless Network Adapter
    GUID                   : xx
    Physical address       : xx
    Interface type         : Primary
    State                  : disconnected
    Radio status           : Hardware On
                             Software On

    Hosted network status  : Not available

Enable or disable with

.\Set-NetAdapterRadioPowerState.ps1 -WifiStatus On
.\Set-NetAdapterRadioPowerState.ps1 -WifiStatus Off

or if no arguments will ask.