-
Notifications
You must be signed in to change notification settings - Fork 1
/
departmentinfo.sh
30 lines (22 loc) · 1.14 KB
/
departmentinfo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
#API login info
apiuser=''
apipass=''
jamfProURL=""
#update via serial number
apiURL="JSSResource/computers/serialnumber"
MacSerial=`system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print $NF}'`
#XML header stuff
xmlHeader="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"
#get current user info from AD
getUser=`ls -l /dev/console | awk '{ print $3 }'`
getclass=`dscl '/Active Directory/ACADEMIC/All Domains' -read /Users/$getUser dsAttrTypeNative:distinguishedName | awk '{ FS=","; print $2 }' | awk '{ FS="="; print $2 }' | tail -1`
getRealName=`dscl '/Active Directory/ACADEMIC/All Domains' -read /Users/$getUser RealName | grep -v ":"`
#API data load
apiData="<computer><location><username>$getUser</username><real_name>$getRealName</real_name><department>$getclass</department></location></computer>"
curl -sSkiu ${apiuser}:${apipass} "${jamfProURL}/${apiURL}/${MacSerial}" \
-H "Content-Type: text/xml" \
-d "${xmlHeader}${apiData}" \
-X PUT > /dev/null
#Old Way
#jamf recon -endUsername $getUser -department "$getclass" -building "Postoak" -realname "$getRealName" -email "[email protected]"