Hi, I'm having a problem with a simple script to force MS AutoUpdate to list and install any updates.
Script works fine as me locally and via Jamf policy, but doesn't show all the results when pushed via policy to all users.
This is the script:
#!/bin/zsh
echo "Start:" $(date)
#Get current logged on user
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
#currentUser=$3
echo "User:" $currentUser
#Set Application path
file="/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app/Contents/MacOS/msupdate"
#if test -f "$FILE"; then
if [ -f "$file" ]; then
echo "Application: Exists"
pkill msupdate
#Use the currentUser to run Microsoft's Update application
list=$( sudo -u "$currentUser" "$file" --list | tail -1 )
echo "List:" $list
if [ "$list" != "No updates available" ]; then
install=$( sudo -u "$currentUser" "$file" --install | tail -1 )
echo "Installed:" $install
fi
fi
echo "Finish:" $(date)
My output:
Start: Tue 2 Aug 2022 17:21:02 BST
User: stephen
Application: Exists
List: No updates available
Finish: Tue 2 Aug 2022 17:21:18 BST
All other users output:
Start: Tue 2 Aug 2022 17:22:02 BST
User: aaaaaa
Application: Exists
List:
Finish: Tue 2 Aug 2022 17:22:02 BST
Notice, no output for List: & Start/Finish times are the same - which makes me think it's not running the sudo commands.
Thanks for your help