Skip to main content
Solved

Collect information about SSID on iMac running BigSur via extension attribute

  • September 15, 2021
  • 4 replies
  • 32 views

Forum|alt.badge.img+4

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

Best answer by bzuidema

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

 

4 replies

Forum|alt.badge.img+4
  • New Contributor
  • 5 replies
  • Answer
  • September 15, 2021

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

 


Forum|alt.badge.img+4
  • Author
  • Contributor
  • 13 replies
  • September 15, 2021

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

 


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 ?


dlbrabb
Forum|alt.badge.img+7
  • Contributor
  • 25 replies
  • September 15, 2021

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 ?


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>"

Forum|alt.badge.img+4
  • Author
  • Contributor
  • 13 replies
  • September 16, 2021

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>"

I confirm that it also works on iMac and MacBook with BigSur. Wonderful people - thanks.