Skip to main content
Question

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


Forum|alt.badge.img+7
  • Contributor
  • 25 replies

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

Forum|alt.badge.img+5
  • New Contributor
  • 11 replies
  • August 22, 2022

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
Forum|alt.badge.img+12
  • Contributor
  • 140 replies
  • August 23, 2022

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 


Forum|alt.badge.img+7
  • Contributor
  • 39 replies
  • August 23, 2022

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.


mvu
Forum|alt.badge.img+20
  • Jamf Heroes
  • 872 replies
  • August 23, 2022

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.

 


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 25 replies
  • August 23, 2022
mickgrant wrote:

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 


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


mickgrant
Forum|alt.badge.img+12
  • Contributor
  • 140 replies
  • August 23, 2022
auser wrote:

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

 


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 25 replies
  • August 23, 2022
mickgrant wrote:

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

 


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.  


mickgrant
Forum|alt.badge.img+12
  • Contributor
  • 140 replies
  • August 23, 2022
auser wrote:

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 


Forum|alt.badge.img+3
  • New Contributor
  • 4 replies
  • May 23, 2023
auser wrote:

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.  


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


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 25 replies
  • May 24, 2023
j09 wrote:

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


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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings