Simple script to notify users to update computer and point to software update

auser
New Contributor III

Hi, does anybody have a simple script to notify users to check for updates and then takes them to the default software update in sys pref? I don't want to use nudge or other software and I don't want to force the update at this point. Basically just a nagging reminder at a set interval. 

Thanks

10 REPLIES 10

patelsanjay
New Contributor III

First idea that comes to mind is to "open" the system pref pane via script. That should just take the user directly to the sofware update interface.

open /System/Library/PreferencePanes/SoftwareUpdate.prefPane 

 Might need to script a Jamf Helper message or similar if you want more user explanation. 

mickgrant
Contributor III

Here is a script I just wrote that should do what you're asking for 

#!/bin/sh
#quick and dirty jamfhelper script to prompt users to run macOS updates
JAMFHELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"

# Get the user's selection
RESULT=`"$JAMFHELPER" -windowType utility -title "You Have Pending Updates" -description "You have a number of updates that are still pending for your Mac please update now" -button1 "Show me" -button2 "Cancel"`

if [ $RESULT == 0 ]; then
    # do button1 stuff
    open /System/Library/PreferencePanes/SoftwareUpdate.prefPane
    echo "Show me was Pressed"
elif [ $RESULT == 2 ]; then
    # do button2 stuff
    echo "Cancel was pressed!"
fi

 

But I still think that you should look into Nudge. You don't need to get complicated with it the only properties you need to use are requiredInstallationDate and requiredMinimumOSVersion 

auser
New Contributor III

Thanks this will work great. However, I am not able to get it to run. Am I missing something?

Are you trying to run it locally or through Jamf?
If you are trying to run it locally to test it, you will need to use chmod to give it the correct permissions.
as a script run by Jamf, it runs as root so it doesn't need any extra permissions

 

auser
New Contributor III

both. I tried locally and the message pops up but when I press show me, I get this; 

-bash: syntax error near unexpected token `fi'. When added to Jamf and scoped to a machine at check in, I can see the policy runs but no pop up. Even with chmod permissions it does not work locally.  

I have only tested it from self-service, and it's working from there.
But a quick search turned up this Jamf nation post about Jamf helper scripts failing when set to check-in - https://community.jamf.com/t5/jamf-pro/jamfhelper-from-check-in-hanging-script/m-p/116074 

j09
New Contributor II

Try this out

#!/bin/sh

currUser=$(ls -l /dev/console | awk '{print $3}')
currUserUID=$(id -u "$currUser")

JAMFHELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"

# Get the user's selection
RESULT=`"$JAMFHELPER" -windowType utility -title "You Have Pending Updates" -description "Your Mac Machine is running with vulnerable version of macOS need to be updated immediately " -button1 "Update Now" -button2 "Cancel"`

if [ $RESULT == 0 ]; then
# do button1 stuff
/bin/launchctl asuser "$currUserUID" sudo -iu "$currUser" open /System/Library/PreferencePanes/SoftwareUpdate.prefPane
echo "Update Now was Pressed"
elif [ $RESULT == 2 ]; then
# do button2 stuff
echo "Cancel was pressed!"
fi

auser
New Contributor III

Thanks, is there a way to adjust the script to add an icon? 

Utilizator
Contributor

We use Nudge - it works well and has an "Agressive" mode to pester people to update to the version we want them on:

https://github.com/macadmins/nudge

Takes a bit of configuring but once you have it installed and running it really does the job.

obi-k
Valued Contributor III

You can put @patelsanjay suggestion in a File & Processes payload. Create a Smart Group of computers with software available updates greater than zero. If any computers have any available updates, run the policy weekly or daily or whatever.

Screen Shot 2022-08-23 at 7.50.37 AM.png