Build a Computer Information script for your Help Desk

talkingmoose
Moderator
Moderator

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"

05b901f8301343f282683f0a1a0b8f47

This Jamf Nation Discussion is for anyone who's needing assistance creating additional modules and/or helping others create modules.

80 REPLIES 80

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')