Hey all,
I am looking for a way to turn Wi-Fi on/off using some commands or running some scripts. Can anyone suggest a way to do this?
Enable/Disable internet connection with commandsSolved
Tags
Replies (4)
You can turn Wi-Fi off using a single line command:
networksetup -setairportpower $AIRPORT off
To turn on, simply replace off with on.
Hi @claus, Looks like @luuk beat us into it
You can turn Wi-Fi off easily from the Hexnode portal requiring absolutely no user interaction by running a custom script.
To learn more, check out the script to turn off Wi-Fi on macOS devices.
Please note that once Wi-Fi is turned off, the end-user has to manually turn on Wi-Fi to restore the internet connectivity.
Hope that helps!
Cheers!
Emma Jones
Hexnode UEM
Hey @Emma, just curious! Is there a reason you didn’t mention the script for turning WiFi on even though it required just changing off to on in the command line?
Hi @mees, you really have an eye for detail!
We have not provided the script for turning Wi-Fi on since to execute custom scripts from the Hexnode portal, an active internet connection on the device is a prerequisite. Since the Wi-Fi would be off before you try to turn it on, remote actions such as running custom scripts cannot be performed on the device.
Looking forward to seeing you more!
Cheers!
Emma Jones
Hexnode UEM