Hi Viking,
I just hadn't included the line in my post but yes the script is showing as yours above above and it behaves the same way i.e on sierra it does not remove the plist and delete the script.
On a separate note I need to amend the script so that :
a) the "install macOS sierra.app" deletes upon download (so not having to wait for it to finish downloading)
b) it deletes the "install macOS sierra.app" IF it appears on the user's desktop so for example if a user copies it from a usb key to their desktop.
Many thanks again.
Here is the current script:
#!/bin/bash
Version=$(sw_vers | grep ProductVersion | tail -c 7 | cut -d . -f 2)
if [ $Version -ge 12 ]
then
launchctl unload /Library/LaunchDaemons/net.sierra.plist
rm -f /Library/LaunchDaemons/net.sierra.plist
rm -f /usr/local/bin/sierra.sh
exit 0
else
rm -rf /Applications/Install\ macOS\ Sierra.app/
# get uid who is running an instance of /System/Library/CoreServices/SystemUIServer.app/Contents/MacOS/SystemUIServer
uid=$(ps -ax -o uid,command | awk '/MacOS\/SystemUIServer/ {print $1}' | head -n1)
# if no such uid is found, exit
[[ -n $uid ]] || exit
# execute osascript by user of the uid
sudo -u "#$uid" osascript <<-'EOF'
tell application "System Events"
activate
display dialog "macOS Sierra is not allowed on computers at this time." with title "Technology Notice" buttons {"OK"} default button 1 giving up after 30
end tell
EOF
fi