So I am currently working on some API extension attribute based scripts, for use with extension attributes.
I have a script working that will do the following:
- List the assigned number of Computers to a user and List it as a number, under a computer device as a extension attribute
- List the assigned number of mobile devices to a user and List it as a number, under a computer device as a extension attribute
# get the number of mobile devices assigned to the user
UserXML=$( /usr/bin/curl \\
--header "accept: application/xml" \\
--request GET \\
--silent \\
--header "Authorization: Bearer $token" \\
--url "$jamfProURL/JSSResource/users/name/$strassigneduser")
#echo "xml results $UserXML"
mobileDevicesCount=$(echo $UserXML | grep -o "<mobile_devices>" | wc -l)
# get the number of mobile devices assigned to the user
UserXML=$( /usr/bin/curl \\
--header "accept: application/xml" \\
--request GET \\
--silent \\
--header "Authorization: Bearer $token" \\
--url "$jamfProURL/JSSResource/users/name/$strassigneduser")
#echo "xml results $UserXML"
computerDevicesCount=$(echo $UserXML | grep -o "<computer>" | wc -l)
These features will help our general operations, but will also allow us to create smart groups from, to identify when a user has both an iPad and a MacBook.
However I want to now add additional code to extract more data. But having some difficulty.
I am now looking at attempting to now export the device ID's from the XML as an array, from the get Users by name API, so that I can leverage the device ID's in a way to:
- list hyper links to the various devices
- exclude unmanaged devices from the results
All my attempts to strip the data into an array of device ID's has been unsuccessful.
Unless there is of course an easier way to do this?