have a script that I'm calling via Self Service and it works perfectly. When I have another policy call the same script, it doesn't work quite right. I'll see in the logs a line:271:370: execution error: No user interaction allowed. (-1713)
below is the script. It has Apple Script at the beginning to popup a window with a list of selections and then ends with basic shell scripting.
#!/bin/sh
nameCode=`/usr/bin/osascript <<EOT
set locations to {"Office 1", "Office 2", "Office 3"}
set choice to (choose from list locations with prompt "Please select the Office that best describes your location")
set city to the result
set code to city as text
if (code = "Office 1") then
set nameCode to "DAL"
else if (code = "Office 2") then
set nameCode to "ATL"
else if (code = "Office 3") then
set nameCode to "BUR"
else
set nameCode to "CORP"
end if
EOT`
sn=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}' | cut -c 5-)
model=$(system_profiler SPHardwareDataType | awk '/Model Name/ {print $3}')
if [[ $model == "MacBook" ]]; then
modelCode="L"
else
modelCode="W"
fi
os="mac"
computerName=$modelCode$nameCode$os$sn
echo "computerName has been set to: $computerName"
networksetup -setcomputername $computerName
scutil --set LocalHostName $computerName
scutil --set HostName $computerName
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName $computerName