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:
~~
1# /bin/bash23#This script is made to change the priority of the Wifi SSID's4#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)5#This has been tested on 10.10 and 10.1167#Sets arguements for script8NetworkDevice=$49PreferredNetwork=$510WirelessSecurity=$611RemoveNetworkAlso=$712#Only fill NetworkDevice if using RemoveNetworkOnly. It will not run the other arguements13RemoveNetworkOnly=$814#Setting argument to anything will trigger this to be run (i.e. asdfasdf) Make sure NetworkDevice is set. Will run with RemoveNetworkOnly15ShowPreferred=$91617#As stated above, if the RemoveNetworkOnly field is populated the script will only run the very last command.18if [ -z $RemoveNetworkOnly ]; then19#Checks if all arguements have been entered, will exit out with statement if no settings have been set.20 if [ -z $NetworkDevice ]; then21 echo "Please set the NetworkDevice"22 exit 123 else24 if [ -z $PreferredNetwork ]; then25 echo "Please set the Preferred Network SSID"26 exit 127 else28 if [ -z $WirelessSecurity ]; then29 echo "Please set the Wireless Security Type" 30 exit 131 else 32 #Echos all arguements33 echo "Network Device is $NetworkDevice" 34 echo "Preferred Network SSID is $PreferredNetwork" 35 echo "Wireless Security Type is $WirelessSecurity" 3637 #Changes Priority of SSID to 038 networksetup -removepreferredwirelessnetwork "$NetworkDevice" "$PreferredNetwork"39 networksetup -addpreferredwirelessnetworkatindex "$NetworkDevice" "$PreferredNetwork" 0 "$WirelessSecurity"4041 #If RemoveNetworkAlso is populated it will run otherwise the script will close42 if [ -z $RemoveNetworkAlso ]; then43 networksetup -removepreferredwirelessnetwork "$NetworkDevice" "$RemoveNetworkAlso"44 else45 echo Done4647 fi48 fi49 fi50 fi51else52 if [ -z $NetworkDevice ]; then53 echo "Please set the NetworkDevice"54 exit 155 else56 if [ -z $RemoveNetworkOnly ]; then57 echo "Unknown error, check to make sure script has not been edited"58 exit 159 else60 networksetup -removepreferredwirelessnetwork "$NetworkDevice" "$RemoveNetworkOnly"61 fi62 fi63fi6465#If arguement is filled with yes it will show preferred list *Warning can be a large list*66if [ -z $ShowPreferred ]; then67 echo Done68else69 networksetup -listpreferredwirelessnetworks "$NetworkDevice"70fi7172exit 0
~~