From 102642c145895f65804a6bb269ab9717d37e2bd7 Mon Sep 17 00:00:00 2001 From: wattsy74 <49881777+wattsy74@users.noreply.github.com> Date: Thu, 28 Oct 2021 15:38:51 +0100 Subject: [PATCH] New --- get-assigned-user-info.sh | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 get-assigned-user-info.sh diff --git a/get-assigned-user-info.sh b/get-assigned-user-info.sh new file mode 100644 index 0000000..c01801c --- /dev/null +++ b/get-assigned-user-info.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# jssUser is the JAMF user with API permissions and can be supplied using Parameter 4 +jssUser=$4 + +# jssPass is the password of the JAMF user with API permissions and can be supplied using Parameter 5 +jssPass=$5 + +# jssHost is the url of the JAMF instance and can be supplied using Parameter 6 +jssHost=$6 + +# Get the serial number of the Mac that the script is running on +SERIAL=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}') + +# Contact the JSS and look up the user information for the Mac's serial number +USERINFO=$(curl -k ${jssHost}/JSSResource/computers/serialnumber/${SERIAL}/subset/location -H "Accept: application/xml" --user "${jssUser}:${jssPass}") + +# Extract the Email Address from the returned user information +EMAILADDRESS=$(echo $USERINFO | /usr/bin/awk -F'|' '{print $2}' | tr [A-Z] [a-z]) + +# Extract the users full name from the returned user information +FULLNAME=$(echo $USERINFO | /usr/bin/awk -F'|' '{print $2}') + +# Extract the users first name from the returned user information by splitting the realname +FIRSTNAME=$(echo $USERINFO | /usr/bin/awk -F'|' '{print $2}'|cut -f1 -d" ") + +# Extract the users last name from the returned user information by splitting the realname +LASTNAME=$(echo $USERINFO | /usr/bin/awk -F'|' '{print $2}'|cut -f2 -d" ") + +# Extract the users position from the returned user information +# POSITION=$(echo $USERINFO | /usr/bin/awk -F'|' '{print $2}') + +# Extract the users phone from the returned user information +# PHONE=$(echo $USERINFO | /usr/bin/awk -F'|' '{print $2}') + +# Extract the users department from the returned user information +# DEPARTMENT=$(echo $USERINFO | /usr/bin/awk -F'|' '{print $2}') + +# Extract the users building from the returned user information +# BUILDING=$(echo $USERINFO | /usr/bin/awk -F'|' '{print $2}') + +# Extract the users room from the returned user information +# ROOM=$(echo $USERINFO | /usr/bin/awk -F'|' '{print $2}') \ No newline at end of file