Wifi - how to change priority

Contributor II

Is there anyway to change priority for SSID on mac´s ?

We have our new 802.1x that I would like to push to 1 place, as it is auto connecting.
And if possible also delete older wifi network

Anyone knows if that is possible by any script etc?


New Contributor III

I tried this script on my machine and was able to add a wifi network to the top of the list and remove an old one. See if it works for you.


# Security type is OPEN for none, WPA for WPA, Personal, WPA2 for WPA2 Personal, WPA/WPA2 for WPA/WPA2 Personal, 
# WPAE for WPA Enterprise, WPA2E for WPA2 Enterprise, WPAE/WPA2E for WPA/WPA2 Enterprise, WEP for plain WEP, 
# and 8021XWEP for 802.1X WEP

#Add Wifi network at top of list
networksetup -addpreferredwirelessnetworkatindex en1 $newSSID 0 $securityType $newPassword

#Remove old SSID
networksetup -removepreferredwirelessnetwork en1 $oldSSID

Honored Contributor II

@jameson The script in this linked post will allow you to promote one or more SSIDs to the top of the Preferred Networks list and works without breaking 802.1x configurations: Preferred Wireless Network priority

New Contributor

For others still looking for a specific approach, I added a Bash implementation and usage guide to this post that @sdagley referenced, which you can see with details here, or just grab the script from this gist.

New Contributor II

@paulr4 -- I noticed that pcregrep is used in this script but is not a default binary to macOS. I cannot just swap with "grep" (it seems to remove ALL my SSIDs) ... do you have a suggestion using binaries that come shipped with macOS?

$ sudo bash Ntwk_WiFiPriority.sh
There are 10 entries in preferred network list.
Ntwk_WiFiPriority.sh: line 52: /usr/local/bin/pcregrep: No such file or directory

$ which pcregrep
$ which grep