Here's a little nugget that you all can enjoy :-)
I wrote this as we are switching our students to a different SSID, however the one they are on currently will still exist. This script changes the wifi preferred list to set the SSID you choose to the top. It also gives the option to remove a SSID of your choice. Another option this script has is to just remove a SSID rather move a SSID in the list. It has been tested on 10.10 and 10.11, it "should" work on 10.9 but I do not have a machine nearby to test it with.
The script has a check to ensure all settings are filled with input or it exits with what is missing. Here is a picture of the script options in Casper:
~~
# /bin/bash
#This script is made to change the priority of the Wifi SSID's
#It has been tested and does not de-auth the user if they are currently on the SSID to be changed (If the SSID password remains in the keychain)
#This has been tested on 10.10 and 10.11
#Sets arguements for script
NetworkDevice=$4
PreferredNetwork=$5
WirelessSecurity=$6
RemoveNetworkAlso=$7
#Only fill NetworkDevice if using RemoveNetworkOnly. It will not run the other arguements
RemoveNetworkOnly=$8
#Setting argument to anything will trigger this to be run (i.e. asdfasdf) Make sure NetworkDevice is set. Will run with RemoveNetworkOnly
ShowPreferred=$9
#As stated above, if the RemoveNetworkOnly field is populated the script will only run the very last command.
if [ -z $RemoveNetworkOnly ]; then
#Checks if all arguements have been entered, will exit out with statement if no settings have been set.
if [ -z $NetworkDevice ]; then
echo "Please set the NetworkDevice"
exit 1
else
if [ -z $PreferredNetwork ]; then
echo "Please set the Preferred Network SSID"
exit 1
else
if [ -z $WirelessSecurity ]; then
echo "Please set the Wireless Security Type"
exit 1
else
#Echos all arguements
echo "Network Device is $NetworkDevice"
echo "Preferred Network SSID is $PreferredNetwork"
echo "Wireless Security Type is $WirelessSecurity"
#Changes Priority of SSID to 0
networksetup -removepreferredwirelessnetwork "$NetworkDevice" "$PreferredNetwork"
networksetup -addpreferredwirelessnetworkatindex "$NetworkDevice" "$PreferredNetwork" 0 "$WirelessSecurity"
#If RemoveNetworkAlso is populated it will run otherwise the script will close
if [ -z $RemoveNetworkAlso ]; then
networksetup -removepreferredwirelessnetwork "$NetworkDevice" "$RemoveNetworkAlso"
else
echo Done
fi
fi
fi
fi
else
if [ -z $NetworkDevice ]; then
echo "Please set the NetworkDevice"
exit 1
else
if [ -z $RemoveNetworkOnly ]; then
echo "Unknown error, check to make sure script has not been edited"
exit 1
else
networksetup -removepreferredwirelessnetwork "$NetworkDevice" "$RemoveNetworkOnly"
fi
fi
fi
#If arguement is filled with yes it will show preferred list *Warning can be a large list*
if [ -z $ShowPreferred ]; then
echo Done
else
networksetup -listpreferredwirelessnetworks "$NetworkDevice"
fi
exit 0
~~