Skip to content

Commit 102642c

Browse files
committed
New
1 parent d313df6 commit 102642c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

get-assigned-user-info.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
# jssUser is the JAMF user with API permissions and can be supplied using Parameter 4
4+
jssUser=$4
5+
6+
# jssPass is the password of the JAMF user with API permissions and can be supplied using Parameter 5
7+
jssPass=$5
8+
9+
# jssHost is the url of the JAMF instance and can be supplied using Parameter 6
10+
jssHost=$6
11+
12+
# Get the serial number of the Mac that the script is running on
13+
SERIAL=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}')
14+
15+
# Contact the JSS and look up the user information for the Mac's serial number
16+
USERINFO=$(curl -k ${jssHost}/JSSResource/computers/serialnumber/${SERIAL}/subset/location -H "Accept: application/xml" --user "${jssUser}:${jssPass}")
17+
18+
# Extract the Email Address from the returned user information
19+
EMAILADDRESS=$(echo $USERINFO | /usr/bin/awk -F'<email_address>|</email_address>' '{print $2}' | tr [A-Z] [a-z])
20+
21+
# Extract the users full name from the returned user information
22+
FULLNAME=$(echo $USERINFO | /usr/bin/awk -F'<realname>|</realname>' '{print $2}')
23+
24+
# Extract the users first name from the returned user information by splitting the realname
25+
FIRSTNAME=$(echo $USERINFO | /usr/bin/awk -F'<realname>|</realname>' '{print $2}'|cut -f1 -d" ")
26+
27+
# Extract the users last name from the returned user information by splitting the realname
28+
LASTNAME=$(echo $USERINFO | /usr/bin/awk -F'<realname>|</realname>' '{print $2}'|cut -f2 -d" ")
29+
30+
# Extract the users position from the returned user information
31+
# POSITION=$(echo $USERINFO | /usr/bin/awk -F'<position>|</position>' '{print $2}')
32+
33+
# Extract the users phone from the returned user information
34+
# PHONE=$(echo $USERINFO | /usr/bin/awk -F'<phone>|</phone>' '{print $2}')
35+
36+
# Extract the users department from the returned user information
37+
# DEPARTMENT=$(echo $USERINFO | /usr/bin/awk -F'<department>|</department>' '{print $2}')
38+
39+
# Extract the users building from the returned user information
40+
# BUILDING=$(echo $USERINFO | /usr/bin/awk -F'<building>|</building>' '{print $2}')
41+
42+
# Extract the users room from the returned user information
43+
# ROOM=$(echo $USERINFO | /usr/bin/awk -F'<room>|</room>' '{print $2}')

0 commit comments

Comments
 (0)