Posted on 09-14-2021 10:35 PM
Hi!
Has anyone managed to get information about the iMac computer's SSID running MacOS BigSur via extensions attribute. If so, how did you do it?
Regards
Solved! Go to Solution.
Posted on 09-15-2021 06:15 AM
Hello,
This is what I have been using to get this information, it works on both M1 and Intel macs as well as all MacOS versions.
#!/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>"
The results look like this
Preferred networks on en1:
Wireless1
Wireless2
09-15-2021 09:18 AM - edited 09-15-2021 10:35 AM
Here's the script that we use for the current SSID connected to:
#!/bin/sh
# Jamf Extension attribute to return SSID
result=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
echo "<result>$result</result>"
Posted on 09-15-2021 06:15 AM
Hello,
This is what I have been using to get this information, it works on both M1 and Intel macs as well as all MacOS versions.
#!/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>"
The results look like this
Preferred networks on en1:
Wireless1
Wireless2
Posted on 09-15-2021 06:51 AM
Big thanks for sharing your script. Do you or someone else have any a clue how to to send back to JSS current wireless SSID which Mac use at the moment ?
09-15-2021 09:18 AM - edited 09-15-2021 10:35 AM
Here's the script that we use for the current SSID connected to:
#!/bin/sh
# Jamf Extension attribute to return SSID
result=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
echo "<result>$result</result>"
Posted on 09-16-2021 12:38 AM
I confirm that it also works on iMac and MacBook with BigSur. Wonderful people - thanks.