@pete_c Have you tested that on macOS 14.5 or later? As of macOS 14.5 I'm seeing "wdutil info" return "<redacted>" for the MAC Address, SSID, and BSSID fields. According to the response to the AppleCare Enterprise case I opened that was an intentional change as Apple considers that information to be a user privacy issue.
Here's the EA I'm currently using to report the active SSID but I don't know that it works on macOS Sonoma Betas (I owe someone credit for posting an example of using networksetup to get this info but I neglected to note where I found it):
#!/bin/sh
result="Not Connected"
WirelessPort=$(/usr/sbin/networksetup -listallhardwareports | /usr/bin/awk '/Wi-Fi|AirPort/{getline; print $NF}')
SSID=$(/usr/sbin/networksetup -getairportnetwork "$WirelessPort" | /usr/bin/awk -F ': ' '{print $2}')
if [ -n "$SSID" ]; then
result="$SSID"
fi
echo "<result>$result</result>"
@pete_c Have you tested that on macOS 14.5 or later? As of macOS 14.5 I'm seeing "wdutil info" return "<redacted>" for the MAC Address, SSID, and BSSID fields. According to the response to the AppleCare Enterprise case I opened that was an intentional change as Apple considers that information to be a user privacy issue.
Here's the EA I'm currently using to report the active SSID but I don't know that it works on macOS Sonoma Betas (I owe someone credit for posting an example of using networksetup to get this info but I neglected to note where I found it):
#!/bin/sh
result="Not Connected"
WirelessPort=$(/usr/sbin/networksetup -listallhardwareports | /usr/bin/awk '/Wi-Fi|AirPort/{getline; print $NF}')
SSID=$(/usr/sbin/networksetup -getairportnetwork "$WirelessPort" | /usr/bin/awk -F ': ' '{print $2}')
if [ -n "$SSID" ]; then
result="$SSID"
fi
echo "<result>$result</result>"
New version tested as working with multi-word SSID names on macOS 13 - 15.
#!/bin/bash
# Report current SSID or "None"
osProductVersion=$( /usr/bin/sw_vers -productVersion )
case "${osProductVersion}" in
12* | 13* | 14* )
wifi=$(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/,/Ethernet/' | awk 'NR==2' | cut -d " " -f 2)
ssid=$(networksetup -getairportnetwork "$wifi" | awk -F': ' '{ print $NF;exit }')
echo "<result>${ssid}</result>"
;;
15* )
ssid=$(wdutil info | awk -F: '/SSID/ { print $NF;exit } ') ; ssid=${ssid:1}
echo "<result>${ssid}</result>"
;;
esac
exit 0
One of the many under-the-hood changes in macOS 15 Sequoia of which Mac Admins should be aware is how to determine a Mac’s currently assigned Service Set Identifier (SSID), commonly known as the name of the user’s selected Wi-Fi network.
Continue reading …
New version tested as working with multi-word SSID names on macOS 13 - 15.
#!/bin/bash
# Report current SSID or "None"
osProductVersion=$( /usr/bin/sw_vers -productVersion )
case "${osProductVersion}" in
12* | 13* | 14* )
wifi=$(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/,/Ethernet/' | awk 'NR==2' | cut -d " " -f 2)
ssid=$(networksetup -getairportnetwork "$wifi" | awk -F': ' '{ print $NF;exit }')
echo "<result>${ssid}</result>"
;;
15* )
ssid=$(wdutil info | awk -F: '/SSID/ { print $NF;exit } ') ; ssid=${ssid:1}
echo "<result>${ssid}</result>"
;;
esac
exit 0
pete_c thank you for the EA! However on Sequoia machines it only returned the <redacted> result. I piecemealed another script I found (cannot remember where from to give credit) but I was able to get it to provide me with the results I was hoping for on our Sequoia machines. Hope this helps someone.
#!/bin/bash
# Report current SSID or "None"
osProductVersion=$( /usr/bin/sw_vers -productVersion )
case "${osProductVersion}" in
12* | 13* | 14* )
wifi=$(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/,/Ethernet/' | awk 'NR==2' | cut -d " " -f 2)
ssid=$(networksetup -getairportnetwork "$wifi" | awk -F': ' '{ print $NF;exit }')
echo "<result>${ssid}</result>"
;;
15* )
ssid=$(system_profiler SPAirPortDataType | awk '/Current Network/ { getline;$1; gsub(":",""); print;exit }') ; ssid=${ssid:1}
echo "<result>${ssid}</result>"
;;
esac
exit 0