EA to get info on the docking station

swapple
Contributor III

I am interested to find out what docking station is being used by our fleet.  We have 2 or 3 that we deploy and some users go out and get their own.  Is there some way for Jamf to detect which dock is connected?

In Terminal, running 

system_profiler SPThunderboltDataType

 I can see the vendor and device name for my dock, but don't see how to script pulling that into an EA.  Plus, not so sure what brands we are looking for so can't just check that.

This might branch out Into a few EAs like vendor/model and firmware version

1 REPLY 1

sdagley
Esteemed Contributor II

@swapple system_profiler will provide results in JSON format, and If your fleet is on macOS Monterey you can use plutil to parse those results. Here's an example on extracting the device name of the first Thunderbolt device attached as an EA:

 

 

#!/bin/bash

# Parsing JSON from system_profiler -json SPThunderboltDataType

jsonData=$(system_profiler -json SPThunderboltDataType)

result=$(/usr/bin/plutil -extract "SPThunderboltDataType".0."_items".0."device_name_key" raw -o - - <<< "$jsonData")

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

 

 

See @franton 's blog post on using plutil to extract specific fields from JSON output: https://richard-purves.com/2021/12/10/plutil-json-parsing-for-fun-and-profit/