Wi-fi extension attribute

ianmb
Contributor

We disable (or at least attempt to disable) wireless access on our Mac desktops, and only allow it on our MacBooks.

Can anybody help me with an extension attribute to report whether the relevant wi-fi interface has been enabled or disabled?

Thanks in advance!

3 REPLIES 3

jason_d
New Contributor III

Test in your environment first but something like this should show if the wireless interface is active or inactive.

#!/bin/sh

#get the wireless interface ID

WirelessPort=$(networksetup -listallhardwareports | awk '/Wi-Fi|AirPort/{getline; print $NF}')

#get interface status

WiFiStatus=$(ifconfig "$WirelessPort" |  grep 'status:' |cut -d: -f2 | awk '{print $1}')

#return status

echo "<result>$WiFiStatus</result>"

stevewood
Honored Contributor II
Honored Contributor II

@ianmb I know you were looking for an EA that would report on status, but I wanted to give you an idea for disabling wireless on your MacPro computers. I use a script to check if there is an Ethernet port active, and if there is it shuts down wireless. This runs using a LaunchDaemon, so the users can try all they like to re-enable WiFi, but if they do not unload the LaunchDaemon it will never work:

Swap Network

I cannot take credit for that script, it was a community effort that was worked out on these discussions:

Disable Airport When Ethernet is Active

Need Help with WiFi Script

This serves two purposes: disables WiFi for those desktop machines that don't need it active, and it ensures your laptop users are not on two networks at once.

jason_d
New Contributor III

Very nice @stevewood thanks for sharing!