Hello everyone - I have created an interactive Apple Script that prompts a user to input their username and it works w/o issue in terminal, but when I have it in Self Service the GUI doesn't come up unless I hit cancel, but it still works which is a plus, but I rather it work like it should and not be a happy little accident.
Also this same script when setting it to run after enrollment completes I get an error of "Script result: 95:158: execution error: No user interaction allowed. (-1713)" Which I believe is because the script is being ran as root?
Here is the script in its entirety. I appreciate you all.
#!/bin/bash
# Prompt the user to enter the new computer name
IFS= read -r -p "Enter the new computer name using department abbreviation and asset tag (Ex:DEPT-123456): " newComputerName
# Execute the AppleScript using osascript
osascript <<-EOF
-- Prompt the user to enter the new computer name
set newComputerName to text returned of (display dialog "Enter the new computer name:" default answer "")
-- Define the shell script commands
set setComputerName to "sudo scutil --set ComputerName " & quoted form of newComputerName
set setLocalHostName to "sudo scutil --set LocalHostName " & quoted form of newComputerName
set setHostName to "sudo scutil --set HostName " & quoted form of newComputerName
-- Execute the shell script commands using osascript and administrator privileges
do shell script setComputerName with administrator privileges
do shell script setLocalHostName with administrator privileges
do shell script setHostName with administrator privileges
EOF