Need a script to turn off wifi when connecting to ethernet

kwoodard
Valued Contributor

Hey all! I am looking for a script that when a laptop is connected to ethernet (either by dongle or docking station) WiFi will turn off. I am having a terrible time with people that plug in their laptops to the docks at their desk and are now connected to ethernet. Even with the service order set to Ethernet as primary or first, the fact that the WiFi is still turned on and connected to a WiFi network that has less privs is making the computer unable to access some internal resources. Once they turn off WiFi, issue is resolved. The WiFi connection is sent out as a configuration profile. I found a script that does this at boot (ethernet has to be plugged in before the computer is turned on), but nothing while on the fly.

Ideas?

2 REPLIES 2

arnoldtaw
New Contributor III

https://github.com/jediknight112/Automatically-Turn-off-WiFi-in-OSX/blob/master/wireless.sh 

This will be a good starting point. You may have to edit the "INTERFACES" from that script depending on the adapter you are using. 

We have a script based on this. For us, we also check to see if the device is on-prem or not by adding a simple ping to one of our servers behind firewall. 

kwoodard
Valued Contributor

I will check that out. I thought about using the network segment info in Jamf Pro to run this while on-prem.