Posted on 08-29-2018 07:50 AM
Jamf published Build a Computer Information script for your Help Desk on the Jamf Blog this morning. In that post I used the term "module" to refer to a short script snippet that can read a piece of information from a Mac and display that information as part of a dialog shown to the end user.
For example, this gets the computer name:
# Display computer name
runCommand=$( /usr/sbin/scutil --get ComputerName )
computerName="Computer Name: $runCommand"
This Jamf Nation Discussion is for anyone who's needing assistance creating additional modules and/or helping others create modules.
Posted on 05-02-2024 03:04 AM
I finally found a solution. Here is the modified script :)
networkServices=$( /usr/sbin/networksetup -listallnetworkservices | /usr/bin/grep -v asterisk )
while IFS= read -r aService
do
activePort=$( /usr/sbin/networksetup -getinfo "$aService" | /usr/bin/grep "IP address" | /usr/bin/grep -v "IPv6" )
if [ "$activePort" != "" ] && [ "$activeServices" != "" ]; then
ipAddress=$(echo "$activePort" | /usr/bin/awk '{print $3}')
macAddress=$( /sbin/ifconfig | /usr/bin/grep -B2 "$ipAddress" | /usr/bin/awk '/ether/ {print $2}')
activeServices="$activeServices\n$aService $activePort MAC: $macAddress"
elif [ "$activePort" != "" ] && [ "$activeServices" = "" ]; then
ipAddress=$(echo "$activePort" | /usr/bin/awk '{print $3}')
macAddress=$( /sbin/ifconfig | /usr/bin/grep -B2 "$ipAddress" | /usr/bin/awk '/ether/ {print $2}')
activeServices="$aService $activePort MAC: $macAddress"
fi
done <<< "$networkServices"
activeServices=$( echo "$activeServices" | /usr/bin/sed '/^$/d')