Script to pull Extension Attribute value and write to AD description field?

hamishedmondson
New Contributor

I'm trying to automate more of my imaging workflow/AD maintenance and this would be really helpful if it's possible.

I know it should be possible to pull a value for a machine's extension attribute using the API, but I don't really know how to achieve it. The EA is called "Client Room" and I'd like to pull that value then write it to the device's description field in AD if that's possible. Does anyone have any pointers here? I've no idea how to even start writing to AD, if it can be done.

Ideally, it'd also be nice to pull both the "Client Room" value another extension attribute, "Client Group", and write those as Apple Remote Desktop info fields 1 and 2. Same deal here, I haven't really worked with the API enough to know where to start, so any help would be very much appreciated.

3 REPLIES 3

thoule
Valued Contributor II

Have a look at https://YourJSSServer.edu/api Getting data from the JSS via the API is pretty easy. You can pull XML or JSON.

#!/bin/sh
server="https://my.school.edu:8443"
curl -H "Accept: application/xml" -sfku "$username:$password" "$server/JSSResource/computerextensionattributes/name/myFavoriteExtension" -X GET | xmllint --format - > /tmp/myFavEA.xml

jgrover
New Contributor

Any advice on how to hide username:password in a script like this? What's best practice from a security point of view?

thoule
Valued Contributor II

https://github.com/jamfit/Encrypted-Script-Parameters

It's a bit of a challenge, but there's one solution that JAMF uses...