Skip to main content
Solved

Collecting active SSID with macOS Sonoma 14.4 and later

  • March 8, 2024
  • 5 replies
  • 662 views

sdagley
Forum|alt.badge.img+25

As of macOS Sonoma 14.4 using "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --getinfo" no longer returns info about the active Wi-Fi connection. If you want to collect the active SSID for macOS 14.4 or later you can use the wdutil tool and here's an EA to do that: 

 

#!/bin/sh

# EA - ActiveSSID
#
# Note: Using wdutil instead of networksetup so I don't need to know what
# interface is Wi-Fi

# Returns the currently active SSID
activeSSID=$(/usr/bin/wdutil info | /usr/bin/awk '/SSID                 :/ { print $NF }')

echo "<result>$activeSSID</result>"

 

Best answer by daniel_behan

This one works for me.

#!/bin/sh

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

##What SSID is the machine connected to
SSID=$(networksetup -getairportnetwork "$WirelessPort" | cut -d " " -f4)

echo "<result>$SSID</result>"

5 replies

DBrowning
Forum|alt.badge.img+25
  • Esteemed Contributor
  • March 8, 2024

If you didn't want to have so many spaces in your call, you can use 

/usr/bin/wdutil info | /usr/bin/awk '/SSID/ { print $NF }' | head -n 1

Forum|alt.badge.img+11
  • Valued Contributor
  • Answer
  • March 11, 2024

This one works for me.

#!/bin/sh

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

##What SSID is the machine connected to
SSID=$(networksetup -getairportnetwork "$WirelessPort" | cut -d " " -f4)

echo "<result>$SSID</result>"


sdagley
Forum|alt.badge.img+25
  • Author
  • Jamf Heroes
  • May 29, 2024

This one works for me.

#!/bin/sh

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

##What SSID is the machine connected to
SSID=$(networksetup -getairportnetwork "$WirelessPort" | cut -d " " -f4)

echo "<result>$SSID</result>"


@daniel_behan As of macOS 14.5 Apple changed 

/usr/bin/wdutil info

to return "redacted" for MAC Address, SSID, and BSSID so calling networksetup as your EA does is currently the only way to get the SSID.

I don't know if whoever at Apple though removing that info from wdutil will do the same to networksetup but here's hoping.


Forum|alt.badge.img
  • New Contributor
  • June 27, 2024

This one works for me.

#!/bin/sh

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

##What SSID is the machine connected to
SSID=$(networksetup -getairportnetwork "$WirelessPort" | cut -d " " -f4)

echo "<result>$SSID</result>"


Is there any way to get the BSSID as well?


jaisonerick
  • New Contributor
  • April 22, 2026

!-->

Picking up the open BSSID question from June: macwifi-cli returns
BSSID alongside SSID, channel, band, and security mode, and is
brew-installable so it ships cleanly via your existing software
distribution:

brew install jaisonerick/tap/macwifi-cli
macwifi-cli info --json
# {"ssid":"corp","bssid":"aa:bb:cc:dd:ee:ff",
# "rssi":-52,"channel":149,"security":"WPA2-Enterprise",
# "current":true,"saved":true}

Caveat for the Jamf use case: it requires Location Services
permission for the helper app on first run, and only works in user
context (so as an Extension Attribute it needs to run from a
logged-in user session, not at all the same as a system-level
collection). For inventory of "what AP is this Mac on right now",
that's usually fine; for "what BSSIDs has this Mac ever seen",
no current API gives you that without the user prompt either.

Disclosure: I built it. macOS 13+ Apple Silicon, Go-based, ships a
Developer-ID-signed and notarized helper bundle inside the binary
to satisfy CoreWLAN's Location-Services-+-stable-signature
requirement. Source:
https://github.com/jaisonerick/macwifi-cli, architecture:
https://jaisonerick.github.io/macwifi/how-it-works.