Hello,
We need to have a dialog prompt so users can name the machines Pre-Jamf enrollment. This script (written as a .COMMAND shell file) seems to work but it'll ask for the current user password, then machine name both in dialogs but then still asks for a password in terminal prior to running. Any ideas?
#!/bin/sh
CurrentUser=$(ls -l /dev/console | cut -d " " -f 4)
currentUserPassword=$(sudo -u $currentUser /usr/bin/osascript <<END
tell application "System Events"
activate
set dialog to (display dialog "Please enter the password for your current account " & "(" & "$currentUser" & ")" & ":" default answer "" with title "$orgName" buttons {"Continue"} default button 1 giving up after 120 with hidden answer)
set answer to text returned of dialog
end tell
return answer
END
)
HOSTNAME=osascript -e 'set T to text returned of (display dialog "Machine Name?" buttons {"Cancel", "OK"} default button "OK" default answer "")'
sudo scutil --set ComputerName $HOSTNAME
sudo scutil --set HostName $HOSTNAME
sudo scutil --set LocalHostName $HOSTNAME
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $HOSTNAME!youtube(link URL)