Can you show the script ? And also what operating system are these computers running ?
@arivera
!/bin/sh
#################################################################################################################
This script was create to update computer information on jamf more specific to Users & Location tab in the jamf pro server
Created by Sebastian Santos on Apr/28/2020. #
#################################################################################################################
This sets the enduser department
Department=`/bin/launchctl asuser 0 /usr/bin/osascript <<EOT
set Department to {"C-Suite", "Engineering", "Finance", "Human Resources", "IT", "Legal", "Marketing", "Professional Services", "Sales", "Sales Engineering", "Tech Support", "N/A"}
set Department to (choose from list Department with prompt "Please select user department:")
set Department to the result
EOT`
echo "$Department"
This sets the enduser building and location as region
Building=`/bin/launchctl asuser 0 /usr/bin/osascript <<EOT
set Building to {"Austin Texas - North America", "American Fork - North America", "Baltimore Maryland - North America", "Boston - CEC - North America", "Champaign - North America", "Herndon - North America", "New York City - North America", "Richardson - North America", "Salt Lake City - North America", "St. Paul - North America", "San Diego - North America", "Remote - North America", "Beijing - APAC", "Sydney - APAC", "Singapore - APAC", "Remote - APAC", "Dublin - EMEA", "Helsinki - EMEA", "Israel Tel Aviv - EMEA", "Krakow - EMEA", "Ra'anana - EMEA", "Ramat Gan - EMEA", "Reading - EMEA", "Remote - EMEA"}
set Building to (choose from list Building with prompt "Please select the State that best describes your building or location:")
set Building to the result
EOT`
echo "$building"
Enduser information
EndUsername=`/bin/launchctl asuser 0 /usr/bin/osascript <<EOT
display dialog "Please enter username here:" default answer "i.e. john.doe or jdoe"
set EndUsername to text returned of the result
EOT`
echo "$EndUsername"
Here we will ask for the enduser position and or bussines role
Position_role=`/bin/launchctl asuser 0 /usr/bin/osascript <<EOT
display dialog "Please enter user position here:" default answer ""
set Position_role to text returned of the result
EOT`
echo "$Position_role"
and OS is Catalina and Mojave
Have you PPPC whitelisted osascript via a configuration profile? Also if you do not have a very helpful piece of software for writing and testing scripts on the go, take a look at CodeRunner. But I also think there are some errors in your script, I am checking right now.
Here's an example of an old script I made for a popup like what you are looking for. This is just a snippet, whatever you end up doing with the results, then thats up to you. Give it a try and maybe you can integrate or use this for your own script I'm sure.
@sebastian.santos Just remember to create a PPPC profile to whitelist osascript for System Events, etc.
#!/bin/sh
loggedInUser=$(stat -f%Su /dev/console)
loggedInUID=$(id -u $loggedInUser)
department=$(/bin/launchctl asuser $loggedInUID sudo -iu $loggedInUser << EOF
/usr/bin/osascript -e 'tell application "System Events"
activate
choose from list {"Sales - Business Development", "Sales - Solutions Consulting", "Sales - Revenue Operations", "Marketing", "CS - Customer Support", "CS - Client Success", "CS - Client Education", "CS - Implementation", "CS - Creative", "Operations - Finance", "Operations - Human Resources", "Product - Product Management", "Product - Product Design", "Engineering - QA", "Engineering - Data Science", "Engineering - Software Engineering", "Engineering - DevOps"} with title "My Company Name" with prompt "Please Select Your Department"
end tell' 2>/dev/null
EOF)
echo $department
@arivera I have whitelisted osascript for system events also the terminal but I always get a pop-up window saying loginwindow wants access to control system events
I will give your script a try thank you so much
As @arivera illustrates it you'll need to launch the process in the user space, not root, or the following will not be displayed to the logged in user:
display dialog "Please enter username here:" default answer "i.e. john.doe or jdoe"
Also, in case you didn't notice
echo "$building"
should be echo "$Building"