How to switch WiFi state on/off with PowerShell & Windows 10?

Question:

I have a tiny .ps1 script which switches a network connection between Ethernet and WiFi. My script works well. I now want to know how to switch off WiFi without disabling the underlying network adapter.

Here is my existing script:

I haven’t been able to find any guidance on how to switch off WiFi via PowerShell (in the same way as it would occur if you clicked the button in the Windows 10 info center). All scripts that I’ve found just disable the underlying adapter, which is not what I want.

Can anybody suggest how to access this functionality from PowerShell?

Answer:

I can’t find any way to do this programmatically, and as a result I think the answer might be that it’s (currently) not entirely possible.

What I have found is that when you use the button in the Windows action center to turn off Wifi, netsh shows the interface as “Hardware On” “Software Off”:

However I can’t see any ability to trigger “Software Off” via netsh or any of the *-netadapter cmdlets. It might be that this is controlled via a switch in the registry but if so I can’t see which.

My recommendation would be to just continue controlling wifi by enabling/disabling the underlying adapter with Disable-NetAdapter and Enable-NetAdapter or if it’s the case that you need to keep the hardware enabled (perhaps in order to reconfigure it?) but want the wireless to be disconnected while you do so, you could connect/disconnect the network via:

Source:

How to switch WiFi state on/off with PowerShell & Windows 10? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply