Posted on 01-13-2022 08:30 AM
Anyone still using a script to manage order of preferred wireless networks in MacOS 11 or above? If so is it working?
We were using the script from Paul Nelson, but since Apple separated the /Library/Preferences/\
SystemConfiguration/com.apple.airport.preferences.plist and put the known-networks in a separate file in
/Library/Preferences/com.apple.wifi.known-networks.plist
it seems like all the old scripts to do this are broken
Posted on 01-20-2022 11:40 AM
I'm also looking for a replacement to the python script since its being depreciated in Monterey.
Posted on 03-25-2022 07:09 AM
Same scenario.
Posted on 06-01-2022 05:59 AM
The same scenario also.
Posted on 06-14-2022 05:26 AM
Looking for a solution to this as well.
Posted on 12-05-2022 07:52 AM
Bumping this one. Anybody made any progress on this or identified a viable solution/alternative to the original script referenced for Wifi/SSID network priority?
12-06-2022 06:26 AM - edited 12-06-2022 06:29 AM
Well I ended up going in a different direction on this. Since we have one network that we want all staff and students to join, and another for guests, I now run a script that looks if they are on the guest IP address and then adds them to a static group that then removes the main network profile, then it removes them from the static group and the network profile then gets re added, which then pushes the main network back to the top I believe.
Its been awhile since I started doing this, but it seems to work really well. So I exclude this static group from the main network profile and its made just for specifically district devices that are on the guest network by mistake.
SO this is scoped to all staff and student devices, but limited to only those with an ip associated with our guest network. Since network changes are reported pretty instantly, this should run immediately once they show up with that IP.
#!/bin/bash
jamfproURL="https://YourJamfServerHere"
groupid="StaticGroupIDnumberHERE"
current_user=$(/bin/ls -l /dev/console | /usr/bin/awk '{print $3}')
action="additions"
APIUser="$6"
APIPass="$7"
ComputerSerial=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}')
xml="<computer_group><computer_${action}><computer><serial_number>$ComputerSerial</serial_number></computer></computer_${action}></computer_group>"
fullURL="${jamfproURL}/JSSResource/computergroups/id/${groupid}"
echo "Created XML"
echo $xml
echo "Jamf API URL"
echo $fullURL
result=$`curl "$fullURL" -u "$APIUser:$APIPass" -H "Content-Type: text/xml" -X PUT -d "$xml"`
echo "result"
echo "$result"
if [[ "$result" == *"<p>The request requires user authentication</p>"* ]] ; then
echo "Add Failed"
else
echo "Add to Static Group probably successful."
fi
exit 0
Then once added to the group, the profile is removed so 2nd script runs to remove it from the same static group:
#!/bin/bash
jamfproURL="YourServerAddressHere"
groupid="YourStaticGroupIDHERE"
current_user=$(/bin/ls -l /dev/console | /usr/bin/awk '{print $3}')
action="deletions"
APIUser="$6"
APIPass="$7"
ComputerSerial=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}')
xml="<computer_group><computer_${action}><computer><serial_number>$ComputerSerial</serial_number></computer></computer_${action}></computer_group>"
fullURL="${jamfproURL}/JSSResource/computergroups/id/${groupid}"
echo "Created XML"
echo $xml
echo "Jamf API URL"
echo $fullURL
result=$`curl "$fullURL" -u "$APIUser:$APIPass" -H "Content-Type: text/xml" -X PUT -d "$xml"`
echo "result"
echo "$result"
if [[ "$result" == *"<p>The request requires user authentication</p>"* ]] ; then
echo "Add Failed"
else
echo "Remove from Static Group probably successful."
fi
exit 0
Then I tell it to remove the guest network from the list of preferred networks so it wont rejoin:
#!/bin/sh
##Get the wireless port ID
WirelessPort=$(networksetup -listallhardwareports | awk '/Wi-Fi|AirPort/{getline; print $NF}')
##Run a SSID removal if its present
networksetup -removepreferredwirelessnetwork $WirelessPort "Princeton Schools Guest" 2>/dev/null
exit 0
So not sure if this helps at all but maybe this is something others can use.