Skip to main content
Solved

Remove Wireless Network (SSID)

  • March 7, 2016
  • 52 replies
  • 410 views

Show first post

52 replies

Forum|alt.badge.img+6
  • Contributor
  • June 20, 2023

I’ve been using my script (posted above) to prune the list of remembered SSIDS in Ventura with no problems.  The core commands should still work. 


TY.  Rereading this post and I'm thinking it's my fault.   Really appreciate your reply.


arajabzadeh
Forum|alt.badge.img+5
  • Contributor
  • January 22, 2024

@sepiemoini If you want to only scope the SSID removal to a Smart Group, then I suggest splitting the script up into 2 discrete scripts.
One would be the EA script, so its capturing the list of saved wireless entries:

#!/bin/sh

##Get the wireless port ID
WirelessPort=$(networksetup -listallhardwareports | awk '/Wi-Fi|AirPort/{getline; print $NF}')

##Collect new preferred wireless network inventory and send back to the JSS
PreferredNetworks=$(networksetup -listpreferredwirelessnetworks "$WirelessPort" | sed 's/^   //g')

echo "<result>$PreferredNetworks</result>"

Then create a Smart Group that would use a "Like" operator to gather any machines that have the specified SSID for removal in their results.
Create a policy that runs the following separate script on it:

#!/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 <WirelessSSID> 2>/dev/null

And use the Smart Group you created before as its scope. Have it run on whatever frequency you want. Important to remember to gather new inventory after it all runs, so hopefully the preferred wireless list will no longer contain the offending SSID and the Mac will fall out of the Smart Group.


Hi is it possible for an SSID not to show even in my wifi list ?