Script to re-order WiFi entries

I am wanting to ensure the main company SSID is always the topmost one and hence the one tried first. I have found several previous discussions here as per the following.


https://www.jamf.com/jamf-nation/discussions/17858/wifi-preference-editing-script

https://www.jamf.com/jamf-nation/discussions/18223/re-order-wifi-preferred-networks


The first one seems to work by deleting and re-creating the SSID to cause it to be re-added to the top. The second one seems to work by editing the plist defining the list of SSIDs. Each has problems.


The recreation of an SSID only works if the credentials of the SSID are available to the script, in our case the one we want listed first uses WPA2 Enterprise authentication with a username and password for each individual and hence this is not going to be possible to include in the script.


The editing of the plist visually appears to work in that the list is reordered as desired and displayed accordingly in Network in System Preferences. The problem is that the Mac does not seem to obey this change because even after a reboot it auto reconnects to the previous choice that is our guest network and does not as intended use the choice based on the order in the list.


I believe the plist that is involved is


/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist


My guess is that the section that lists the SSIDs and their order has been edited by the script but maybe a different section defining either the last SSID used or the one to default to is not.

Is anyone able to suggest a solution?

Posted on Feb 13, 2020 6:41 AM

Reply

Similar questions

3 replies

Feb 13, 2020 7:54 AM in response to John Lockwood

/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist


Way down at the end is the PreferredOrder key. Can you try manually re-ordering them? Xcode sorts them into Item 0, Item 1 etc but you might try just editing the file. I haven't tried it.


I agree the jamf scripts have a variety of problems. macOS might decide to reorder them on its own anyway, regardless of what you do.


... maybe a different section defining either the last SSID used or the one to default to is not.


That's possible. I'm afraid I don't have the answer. If there is one, jamf nation is likely to be more helpful.

Feb 13, 2020 8:44 AM in response to John Galt

Thanks for the response John.


Yes the PreferredOrder section at the bottom is what I suspect the script is modifying but this alone as I mentioned does not seem to accomplish the goal. I can see there are also entries for each of the two SSIDs I am concerned with listing 'LastConnected' date/time.


<key>LastConnected</key>
<date>2020-01-28T13:09:50Z</date>


Perhaps the OS is using that information to use the most recent one i.e. the one I want to switch away from. I will see if I can work out how to update that value. Also I would be willing to disable auto connect for the guest network and that is a simple True/False flag.


<key>Disabled</key>
<true/>


Knowing how obtuse Apple can be these days it is not impossible that there is another hidden setting in some totally different file or even SQLite database somewhere else. (As an example the list of entries in a users dock is now well hidden.)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Script to re-order WiFi entries

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.