Skip to main content
Solved

Run policy after setup screen?

  • November 21, 2022
  • 4 replies
  • 33 views

ganidran
Forum|alt.badge.img+6

Hi folks. Tried searching but couldn't find a solution (if any) to running a policy after the first setup screen is finished? We've found that some users get their laptops early, go through setup, hit enrollment and leave their computer only to finish that setup later in the day or the next day. We have a few policies that run after enrollment but require a logged in user to be present (some people haven't even created the user in the setup screen yet). 

 

Hope that made sense! Thanks all :D

Best answer by mickgrant

I have an enrollment script that runs on the enrollment complete trigger.
Inside that script, I call all my other policies with custom triggers, but before they are called, there is a little bit of logic that runs to make sure that the setup assistant process is no longer running.

# # Check if Setup Assistance Process is Still Running. # If yes, wait till it finishes so this script will NOT proceed while running the Setup Assistant (Location Settings..etc) # SetupAssistance_process=$(/bin/ps auxww | grep -q "[S]etup Assistant.app") while [ $? -eq 0 ] do /bin/echo "Setup Assistant Still Running... Sleep for 2 seconds..." /bin/sleep 2 SetupAssistance_process=$(/bin/ps auxww | grep -q "[S]etup Assistant.app") done




4 replies

Forum|alt.badge.img+8
  • Valued Contributor
  • November 21, 2022

Typically, an enrollment complete trigger will start when the login screen appears. This happens with DEP Notiy for after. 


mickgrant
Forum|alt.badge.img+12
  • Contributor
  • Answer
  • November 22, 2022

I have an enrollment script that runs on the enrollment complete trigger.
Inside that script, I call all my other policies with custom triggers, but before they are called, there is a little bit of logic that runs to make sure that the setup assistant process is no longer running.

# # Check if Setup Assistance Process is Still Running. # If yes, wait till it finishes so this script will NOT proceed while running the Setup Assistant (Location Settings..etc) # SetupAssistance_process=$(/bin/ps auxww | grep -q "[S]etup Assistant.app") while [ $? -eq 0 ] do /bin/echo "Setup Assistant Still Running... Sleep for 2 seconds..." /bin/sleep 2 SetupAssistance_process=$(/bin/ps auxww | grep -q "[S]etup Assistant.app") done





karthikeyan_mac
Forum|alt.badge.img+18
  • Honored Contributor
  • November 22, 2022

@ganidran You can also check for the Dock and execute after the Dock is launched.

 

#!/bin/bash # # Script to check and keep looping till the Dock is loaded # This can be used to launch or execute app or script after the Dock loads. # # dockStatus=$(pgrep -x Dock) echo "Waiting for Dock to launch" while [[ "$dockStatus" == "" ]] do echo "Dock is not loaded. Waiting" sleep 5 dockStatus=$(pgrep -x Dock) done sleep 5 loggedinUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }') echo "Dock loaded with $dockStatus for user $loggedinUser" # # Add your scripts or commands here to execute after the Dock is loaded exit 0

 


ganidran
Forum|alt.badge.img+6
  • Author
  • Contributor
  • November 22, 2022

These two are helpful! Didn't even think to check for the dock or to make sure setup assistant is done. Thanks folks!