Files
Alte_Skripte/de.ing.update_user_info.sh
2026-02-16 15:05:15 +01:00

33 lines
1.4 KiB
Bash

#!/bin/bash
##########################################################################
# Shellscript : Update Username in Jamf Record
# Autor : Jobst Heinermann, macenterprise gmbh
# Quelle : https://www.jamf.com/jamf-nation/discussions/17139/assign-users-to-computers-via-api
# Copyright : macenterprise 2019
##########################################################################
aduser=$(dscl . list /Users | grep -v '_' | sort -ug | tail -n1)
if [ $aduser -gt 10000 ]
then
# -endUsername The user name of the primary user
endUsername=$(dscl . read /Users/$aduser RecordName | awk {'print $2'})
# -realname The real name of the primary user
realname=$(dscl . read /Users/$aduser RealName | tr -d ' ' | tail -n1)
# -email The email address of the primary user
email=$(dscl . read /Users/$aduser EMailAddress | awk {'print $2'})
# -position The position (job title) of the primary user
position=$(dscl . read /Users/$aduser JobTitle | tr -d ' ' | tail -n1)
# -phone The phone number of the primary user
phone=$(dscl . read /Users/$aduser PhoneNumber | tr -d ' ' | tail -n1)
# -building The text representation of a building in the jSS
building=enrolled
jamf recon -endUsername "$endUsername" -realname "$realname" -email "$email" -position "$position" -phone "$phone" -building "$building"
else
echo "kein AD User vorhanden"
exit 1
fi