Refresh Self Service via Files and Processes Payload Execute Command

dan-snelson
Valued Contributor II

Background

While adding opt-in and opt-out Self Service policies to Jamf Pro 10, we wanted a way to force Self Service to refresh so new testers would immediately see available testing policies.


Script

Add the Files and Processes Payload to your policy, then insert the following code into the Execute Command field:

/usr/bin/su - "`/usr/bin/stat -f%Su /dev/console`" -c "/usr/bin/osascript -e 'tell application "Self Service" to activate' -e 'tell application "System Events" to keystroke "r" using {command down}'"

d89a95428cdd45d89765dade2021b7aa

Self Service should refesh after the policy is executed. (As always, your mileage may vary.)


Related Posts

@rhs615's Command to Refresh Self-Service

@timdambrosio's Self Service refresh/home via command line

6 REPLIES 6

npynenberg
Contributor

Great tip! Definitely see uses for this. Thank you.

kfjamf
New Contributor III

Just used this, thanks.

Modified it as follows for forcing the user to view the description, adding in an Esc key press before the refresh:

/usr/bin/su - "`/usr/bin/stat -f%Su /dev/console`" -c "/usr/bin/osascript -e 'tell application "Self Service" to activate' -e 'tell application "System Events" to key code 53' -e 'tell application "System Events" to keystroke "r" using {command down}'"

jaredgrieve
New Contributor II

I made a silly mistake and spent some time trying to figure it out. For the next person that does the same here is my ah-hah moment which is admittedly a "well ya, duh" kind of thing.

If you opted to rebrand Self Service especially the name of the application not just the icon. You will need to change the "Self Service" in the command to "Whatever you renamed Self Service to"... I had added our school districts initials to Self Service in addition to changing the icon to the school logo to make it as familiar as possible.

dan-snelson
Valued Contributor II

Thanks for your racing-stripe, @kfbbt.

You'll also need the following Privacy Preferences Policy Control settings nowadays:

  • Identifier: com.jamf.management.service
  • Identifier Type: Bundle ID
  • Code Requirement: anchor apple generic and identifier "com.jamf.management.service" and (certificate leaf[field.1.2.840.113635.100.6.1.9] / exists / or certificate 1[field.1.2.840.113635.100.6.2.6] / exists / and certificate leaf[field.1.2.840.113635.100.6.1.13] / exists / and certificate leaf[subject.OU] = "483DWKW443")
  • App or Service: Accessibility
  • Access: Allow

4cb45af76acc46418231182dfe4022da

Googolplex
New Contributor

Has anyone managed to get this to work on Monterey? I am getting the following error, and unfortunately I can't see how to fix it or what causes it "exactly"..

zsh:1: unmatched '

dan-snelson
Valued Contributor II

@Googolplex The following just worked for me in a single test on macOS 12.0.1 (21A559).

/usr/bin/su \- "`/usr/bin/stat -f%Su /dev/console`" -c "/usr/bin/osascript -e 'tell application \"Self Service\" to activate' -e 'tell application \"System Events\" to key code 53' -e 'tell application \"System Events\" to keystroke \"r\" using {command down}'"