Thursday
I have made a script, with help from other scripts found online, that will take user input and then update user information on JAMF Pro.
All working apart from where you enter the staff/students full name for example "John Smith", script is only reading the first word on the input and updating JAMF = John. Been on this for a few hours trying anything that I can find and now I am at a loss of what I can try to sort this.
Any help on this would be very welcome :)
JAMF_FULLNAME=`/usr/bin/osascript << EOT
tell application "System Events"
activate
set JAMF_FULLNAME to text returned of (display dialog "Please enter fullname " default answer "")
end tell
EOT`
#Store input full name
echo $JAMF_FULLNAME
-------------------------------------------------------------------------------------------------------
Complete script for information:
#!/bin/sh
echo ""
#1. Get user input for username
JAMF_USERNAME=`/usr/bin/osascript << EOT
tell application "System Events"
activate
set JAMF_USERNAME to text returned of (display dialog "Please YYD Username " default answer "")
end tell
EOT`
#Store input for username
echo $JAMF_USERNAME
wait
echo ""
#2. Get user input for full name
JAMF_FULLNAME=`/usr/bin/osascript << EOT
tell application "System Events"
activate
set JAMF_FULLNAME to text returned of (display dialog "Please enter fullname " default answer "")
end tell
EOT`
#Store input full name
echo $JAMF_FULLNAME
wait
echo ""
#3. Get user input for email
JAMF_EMAIL=`/usr/bin/osascript << EOT
tell application "System Events"
activate
set JAMF_EMAIL to text returned of (display dialog "Please YYD email " default answer "")
end tell
EOT`
#Store input for email
echo $JAMF_EMAIL
wait
echo ""
#4. Get user input for job role
JAMF_POSITION=`/usr/bin/osascript << EOT
tell application "System Events"
activate
set JAMF_POSITION to text returned of (display dialog "Please enter job role (i.e. Teacher, ICT Support, Head Teacher) " default answer "")
end tell
EOT`
#Store input job role
echo $JAMF_POSITION
wait
echo ""
#5. Get user input for site
JAMF_BUILDING=`/usr/bin/osascript << EOT
tell application "System Events"
activate
set JAMF_BUILDING to text returned of (display dialog "Please enter YD site (PLC, DN, LD) " default answer "")
end tell
EOT`
#Store input for site
echo $JAMF_BUILDING
wait
echo ""
#6. Get user input for YD asset
JAMF_ASSET=`/usr/bin/osascript << EOT
tell application "System Events"
activate
set JAMF_ASSET to text returned of (display dialog "Please enter YD asset " default answer "")
end tell
EOT`
#Store input for YD asset
echo $JAMF_ASSET
wait
echo ""
#Send user input to JAMF Pro instance
sudo jamf recon -skipPlugins -skipFonts -skipApps -assetTag ${JAMF_ASSET} -position ${JAMF_POSITION} -realname ${JAMF_FULLNAME} -email ${JAMF_EMAIL} -endUsername ${JAMF_USERNAME} -building ${JAMF_BUILDING}
Solved! Go to Solution.
Thursday
That makes sense. So to get your script to work I added quotes around the variable so it reads it as a string. Here is the snippet I changed:
sudo jamf recon -skipPlugins -skipFonts -skipApps -realname "$JAMF_FULLNAME"
Thursday - last edited Thursday
A couple of questions is your Jamf instance connected to either LDAP or a cloud IDP? Also take a look at swiftDialog, it's much more robust than osascript and you can design one window that grabs all this information.
Thursday
Thank you for the response sharriston, Cloud using entra id, single signon works that does populate user information but due to MF we cannot enter the information to register the user against JAMF. So looking for an easier was to update user information.
I had a go at SwiftDialog and couldn't get it to work.
Thursday
Are your users shortnames the same as their entra ID?
Thursday
Yes I believe that they are, using the above script to also updates role, building and asset.
Thursday
That makes sense. So to get your script to work I added quotes around the variable so it reads it as a string. Here is the snippet I changed:
sudo jamf recon -skipPlugins -skipFonts -skipApps -realname "$JAMF_FULLNAME"
Thursday
I've been using this successfully for years.
#!/bin/sh
user=$(stat -f%Su /dev/console)
/usr/local/jamf/bin/jamf recon -endUsername $user
Thursday
You are a genius, that worked a treat.
I appreciate your help so much, thank you kind stranger!
David
Thursday
We finally made the move to JAMF Connect, here's a snippet
ADuser=$(stat -f%Su /dev/console)
UserName=$ADuser@yourcompanyemail.com
RealName=`finger $ADuser | grep "Name:" | awk '{print $4" "$5" "$6}'`
eMail=$UserName
/usr/local/bin/jamf recon -skipPlugins -skipFonts -skipApps -endUsername "$UserName" -realname "$RealName" -email "$eMail"
@sharriston missed you at last meet up