For my use case, I require the following:
- Identify current WiFi network (SSID name)
- Connect to specific WiFi network (by SSID)
- Scan for nearby WiFi networks (SSID names)
I can work around issues 1 and 2 but have yet to find a commandline-capable workaround for issue 3.
Issue 1
/usr/sbin/networksetup -getairportnetwork en0 | grep 'Current Wi-Fi Network: ' | sed 's/Current Wi-Fi Network: //g'
Issue 2
networksetup -setairportnetwork en0 "<SSID>" "<PASSWORD>"
It seems that getting SSID names requires Location Service permissions, which apparently is not possible(??) with in-house commandline utilities (e.g. Python scripts) even when using libraries like pyobjc to request Location Services permissions via Objective-C hooks. This is a problem for my automation team.
We found some success by writing a tiny Swift app that requests Location Services permission and then does the scan but have not been able to get a commandline version of the app to work yet.
For the sake of developers who understand the risks, requesting that Apple allow manual addition of apps/scripts/binaries to have Location Services permissions so we can get back to work.