Posted on 01-25-2016 01:30 PM
I've read through https://jamfnation.jamfsoftware.com/discussion.html?id=5968 and I've looked at the apiFrontPage.rest page. I can see how I can get things like a list of departments, but how can I get the department a machine is part of?
I'm working on a shell script that will hopefully be using different registration codes to register the app based on the department the machine is part of.
Posted on 01-25-2016 01:56 PM
#!/bin/sh
## API details with computer read privs
apiUser="apiusername"
apiPass="apipassword"
jssURL="https://your.jss.com:8443"
## Get the computer's name
compName=$(scutil --get ComputerName)
## Possible strings to use below:
## "username"
## "real_name"
## "email_address"
## "position"
## "phone"
## "department"
## "building"
## "room"
section="department"
LocationData=$(curl -H "Accept: text/xml" -sfku "${apiUser}:${apiPass}" "${jssURL}/JSSResource/computers/macaddress/$(networksetup -getmacaddress en0 | awk '{print $3}')/subset/location" | xmllint --format - 2>/dev/null | grep "<${section}" | awk -F'>|<' '{print $3}')
echo "$section assigned to $compName is: $LocationData"