HexCon is coming to NYC. Catch the early-bird price before the time's up! Book me a spot

Enable/Disable internet connection with commandsSolved

Participant
Discussion
3 years ago

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?

Replies (4)

Marked SolutionPending Review
Participant
3 years ago
Marked SolutionPending Review

You can turn Wi-Fi off using a single line command:
networksetup -setairportpower $AIRPORT off

To turn on, simply replace off with on.

Marked SolutionPending Review
Hexnode Expert
3 years ago
Marked SolutionPending Review

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

Marked SolutionPending Review
Participant
3 years ago
Marked SolutionPending Review

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?

Marked SolutionPending Review
Hexnode Expert
3 years ago
Marked SolutionPending Review

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