Skip to main content
Solved

How are computer extensions actually meant to work

  • February 13, 2024
  • 4 replies
  • 16 views

Forum|alt.badge.img+7

I'm trying to establish the last time a user actually logged in to their laptop. I have, therefore, created a Computer Extension that runs a simple script that is supposed to display a String result in User and Location:

#!/bin/zsh

/usr/bin/last -1 -t console | <result>/usr/bin/awk '{print $4, $5, $6}'

I added the Computer Extension to the Configuration Profile under ALLOWED EXTENSIONS but nothing ever seems to be displayed. How are Computer Extensions actually meant to work, i.e. how am I meant to actually see the data that is gathered???

Best answer by sdagley

@VL35_2 You need to use the proper form of the result tag to bracket what your EA returns, e.g. 

#!/bin/sh result=$(/usr/bin/last -1 -t console | /usr/bin/awk '{print $4, $5, $6}') echo "<result>$result</result>"

4 replies

AJPinto
Forum|alt.badge.img+26
  • Legendary Contributor
  • February 13, 2024

Are you trying to deploy an Extension Attribute? If so, the command is not valid, Jamf also reports when a user logs in within the devices inventory record granted you cannot make searches for this data.


Forum|alt.badge.img+7
  • Author
  • Contributor
  • February 13, 2024

OK, I got the Configuration Profile > Extensions mixed up with Computer Extension, but still not seeing any data gathered.


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • Answer
  • February 13, 2024

@VL35_2 You need to use the proper form of the result tag to bracket what your EA returns, e.g. 

#!/bin/sh result=$(/usr/bin/last -1 -t console | /usr/bin/awk '{print $4, $5, $6}') echo "<result>$result</result>"

AJPinto
Forum|alt.badge.img+26
  • Legendary Contributor
  • February 13, 2024

OK, I got the Configuration Profile > Extensions mixed up with Computer Extension, but still not seeing any data gathered.


Your formatting is off, an EA needs the <results> tag for Jamf to know what do report from the script.

 

Something like the script below will work, just tinker with what you want the results to be. This script will report the last 3 login events, and could be adjusted to the last login event and grep or awk to filter beyond that.

#!/bin/bash # Get the first 3 login events last_entries=$(last -3) # Display the information if [ -n "$last_entries" ]; then echo "First 3 login events:" echo "<result>$last_entries</result>" else echo "<result>No recent login information found.</result>" fi