Skip to main content
Jamf Nation, hosted by Jamf, is a knowledgeable community of Apple-focused admins and Jamf users. Join us in person at the ninth annual Jamf Nation User Conference (JNUC) this November for three days of learning, laughter and IT love.

Creating Extension Attributes Populated by a Custom Script

Overview

Manually-created extension attributes can be populated by hand in a text field or pop-up menu, or by running a custom script. This article contains guidelines for running a custom script to populate manually-created extension attributes.

If you choose to populate an extension attribute using a custom script, any text returned to stdout between the <result></result> tag is stored in Jamf Pro when the script runs.

For example, the following script can be used to populate a “Last User” extension attribute in Jamf Pro:

#!/bin/sh
lastUser=`/usr/bin/last -1 -t console | awk '{print $1}'`

if [ $lastUser == "wtmp" ]; then
   echo "<result>No logins</result>"
else
   echo "<result>$lastUser</result>"
fi

Requirements

Access to Jamf Pro is required to create an extension attribute populated by a custom script.

Procedure

To access additional examples of extension attribute scripts:

  1. Log in to Jamf Pro with a web browser.
  2. In the top-right corner of the page, click Settings.
  3. Click Computer Management. On a smartphone, this option is in the pop-up menu.
  4. In the "Computer Management-Management Framework" section, click Extension Attributes.
  5. Click New From Template.
  6. Click the extension attribute template for which you would like to view a script.
Like Comment
Order by:
SOLVED Posted: by desktopengineers

Is it possible to have a script that prompts the user to choose "personal" or "company owned" and have that choice populate an extension attribute field?

Like
SOLVED Posted: by loceee

Patchoo has a bunch of code that will read, prompt and update computer data from the API.

This can read your ext attribute
https://github.com/patchoo/patchoo/blob/master/0patchoo.sh#L1443
http://

Writing...
https://github.com/patchoo/patchoo/blob/master/0patchoo.sh#L1476

https://github.com/patchoo/patchoo/blob/master/0patchoo.sh#L1523

Pretty rough and ready but it gets the job done.

Like
SOLVED Posted: by viswa

user login time along with year script or extensions attribute.

can anyone aware of how to get the last login details of user with date. last command gives only time and month. is there a way to fetch year details too. please assist

Like