Set up Extension Attribute(?) to capture connected USB devices and monitors

heavymeta80
New Contributor III

I had asked this as a reply to a solved issue but I figured I would open a new conversation here.

 

I've been asked if we can have Jamf Pro capture information (type, serial number, etc.) USB devices and monitors are attached to our managed computers. I've seen on forums that this can be done with the an Extension Attribute utilizing system_profiler but I haven't found clear instructions on how to set this up. I found that running "system_profiler SPDisplaysDataType" and "system_profiler SPUSBDataType" from Terminal provides the info I need but I'm stumped on how to have those commands run in Jamf so the info populates per machine.

Thanks in advance!

9 REPLIES 9

obi-k
Valued Contributor III

In Jamf, did you go to?

• Settings -> Computer management ->Extension attributes

Once you enter your EA script, run inventory on the Mac and you'll see the info in the computer inventory record field.

heavymeta80
New Contributor III

Yes, I know how to add the script to Jamf. I just don't know how to write the script itself. Scripting is a bit of a weakness for me I admit.

obi-k
Valued Contributor III

One of the EAs I am using for monitors:

 

#!/bin/sh

displays=$(system_profiler SPDisplaysDataType -xml | grep -A2 "</data>" | awk -F'>|<' '/_name/{getline; print $3}')

echo "<result>$displays</result>"

exit 0

jamf-42
Valued Contributor II

nice.. but the return of 'Color LCD' is taking me back to the 90s 🤣 

heavymeta80
New Contributor III

LOL oh yeah, me too

heavymeta80
New Contributor III

Thank you, I can view that info as part of a search by checking the box for it under Inventory Display but it's not showing up in Extension Attributes for computers that just ran inventory. I tried looking for that setting in Jamf and also Googling it but came up empty.

heavymeta80
New Contributor III

Also, I tried using your script with SPUSBDataType and it doesn't return any results like the other script does.

cwaldrip
Valued Contributor

Keep in mind that the EA will only capture the devices when it runs and they're attached. If it's really important you can setup a LaunchDaemon to run every 15 minutes, or maybe on device connection if you can work that out, and save the information in a log file. Maybe even check for duplicate entires and ignore them if you just want a list of what's attached and not when or for how long it's attached. Then your EA can grep the results of that log file. As part of the LaunchDaemon to maybe flush that log file.

heavymeta80
New Contributor III

It's not important for the info to be collected more frequently than the normal inventory. The issue is getting the EA to appear under Extension Attributes when viewing the computer information as well as configuring the script with the SPUSBDataType so USB device info can be captured. Just duplicating the script and swapping SPDisplaysDataType for SPUSBDataType doesn't return any results.