Help With Computer Naming Script

lsv
New Contributor III

I've been poking through old threads and came across this thread which helped me create a script that accomplishes most of what I'm trying to do with naming machines. I have a script that works as intended, but there are 2 things I was hoping to change and can't quite figure out the best way to accomplish them. 

Firstly, when I run this script it doesn't seem to wait for user input to continue. If I leave the first pop up open for a minute or so, it will automatically go to the next prompt, without receiving input from the end user. Is there a way to conditionally require that the end user has to select "Continue" before the next prompt is shown?

Secondly, is there a way to add particular images/icons to these prompts? As of right now the prompts could be misinterpreted as suspicious with no company logo attached (screenshot below)

Screen Shot 2022-05-04 at 12.30.20 PM.png

Apologies if these questions are a bit rudimentary, I'm fairly new to the scripting process. I've included the full script below, I appreciate any guidance! 

#!/bin/sh

#  Name Your Computer.sh

#The user will be notified that we are going to change the name of their computer
firstName=$(/usr/bin/osascript << EOD
tell application "System Events"
activate
set AssetTag to text returned of (display dialog "We are running a policy that will rename your machine, press continue to begin the process (this will take 1 minute)." buttons {"Continue"} default button 1)
end tell
EOD)

#The user will input the value of their first name

firstName=$(/usr/bin/osascript << EOD
tell application "System Events"
activate
set AssetTag to text returned of (display dialog "What is your first name?" default answer "" buttons {"Continue"} default button 1)
end tell
EOD)

#The user will input the value of their first name

lastName=$(/usr/bin/osascript << EOD
tell application "System Events"
activate
set AssetTag to text returned of (display dialog "What is your last name?" default answer "" buttons {"Continue"} default button 1)
end tell
EOD)

#The user will input the value of their first name

email=$(/usr/bin/osascript << EOD
tell application "System Events"
activate
set AssetTag to text returned of (display dialog "What is your veda email?" default answer "" buttons {"Continue"} default button 1)
end tell
EOD)

#The user will choose their department from a drop down menu

dept=$(/usr/bin/osascript << EOD
tell application "System Events"
activate
set Department to (choose from list {"Corporate", "Delivery", "Marketing", "Sales", "Science", "Success", "Technology"} with title "Departments" with prompt "Please choose your department")
end tell
EOD)


#gets current logged in user
getUser=$(ls -l /dev/console | awk '{ print $3 }')

#Groups first and last name
realName="$firstName $lastName"

#Takes the data collected from the user and sets it as the Computer Name and submits the name to the Jamf API
deviceName="$realName - Macbook Pro"

#Set all the name in all the places
/usr/local/bin/jamf setcomputername -name "$deviceName"
/usr/local/bin/jamf recon -endUsername "$firstName$lastName" -realname "$realName" -email "$email" -position " " -building "test bldg" -department "$dept" -phone " " -room " "

 

1 REPLY 1

lsv
New Contributor III

I was able to get custom images set up, but am still trying to figure out how to wait for user input before the next prompts are given. Updates script below:

#!/bin/sh

#  Name Your Computer.sh

#Get logged in user info
loggedInUser=$3

#Icon location
brandingImage="/Users/$loggedInUser/Library/Application Support/com.jamfsoftware.selfservice.mac/Documents/Images/brandingimage.png"

#The user will be notified that we are going to change the name of their computer
firstName=$(/usr/bin/osascript << EOD
tell application "System Events"
activate
set AssetTag to text returned of (display dialog "We are running a policy that will rename your machine, press continue to begin the process (this will take 1 minute)." buttons {"Continue"} default button 1 with icon posix file "$brandingImage")
end tell
EOD)

#The user will input the value of their first name

firstName=$(/usr/bin/osascript << EOD
tell application "System Events"
activate
set AssetTag to text returned of (display dialog "What is your first name?" default answer "" buttons {"Continue"} default button 1 with icon posix file "$brandingImage")
end tell
EOD)

#The user will input the value of their first name

lastName=$(/usr/bin/osascript << EOD
tell application "System Events"
activate
set AssetTag to text returned of (display dialog "What is your last name?" default answer "" buttons {"Continue"} default button 1 with icon posix file "$brandingImage")
end tell
EOD)

#The user will input the value of their first name

email=$(/usr/bin/osascript << EOD
tell application "System Events"
activate
set AssetTag to text returned of (display dialog "What is your veda email?" default answer "" buttons {"Continue"} default button 1 with icon posix file "$brandingImage")
end tell
EOD)

#The user will choose their department from a drop down menu

dept=$(/usr/bin/osascript << EOD
tell application "System Events"
activate
set Department to (choose from list {"Corporate", "Delivery", "Marketing", "Sales", "Science", "Success", "Technology"} with title "Departments" with prompt "Please choose your department")
end tell
EOD)


#gets current logged in user
getUser=$(ls -l /dev/console | awk '{ print $3 }')

#Groups first and last name
realName="$firstName $lastName"

#Takes the data collected from the user and sets it as the Computer Name and submits the name to the Jamf API
deviceName="$realName - Macbook Pro"

#Set all the name in all the places
/usr/local/bin/jamf setcomputername -name "$deviceName"
/usr/local/bin/jamf recon -endUsername "$firstName$lastName" -realname "$realName" -email "$email" -position " " -building "test bldg" -department "$dept" -phone " " -room " "