Skip to content

Instantly share code, notes, and snippets.

@krispayne
Created October 25, 2016 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krispayne/b3a7c5e469bae1cfdf85cffb9d39c1f1 to your computer and use it in GitHub Desktop.
Save krispayne/b3a7c5e469bae1cfdf85cffb9d39c1f1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Extension attribute to find if bad network is on device
# Modified from:
# Lauren Caliolio 8/22/2014
# Contact me: laurendc@gmail.com, twitter @laurendc or JAMFNation: laurendc
# Wireless network to hunt
HUNT="old-public-ssid"
# Find device on hardware irregardless of model
WIFI_DEVICE=$(/usr/sbin/networksetup -listallhardwareports | /usr/bin/egrep -A2 'Airport|Wi-Fi' | /usr/bin/awk '/Device/ { print $2 }')
# Get name of preferred wireless network that's first on the list
FIRST=$(/usr/sbin/networksetup -listpreferredwirelessnetworks $WIFI_DEVICE | /usr/bin/awk '{if (NR!=1) { print $1 }}' | /usr/bin/grep "${HUNT}")
if [[ ${FIRST} = ${HUNT} ]]; then
RESULT="True"
else
RESULT="False"
fi
/bin/echo "<result>"${RESULT}"</result>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment