Run policy after setup screen?

ganidran
New Contributor III

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

1 ACCEPTED SOLUTION

mickgrant
Contributor III

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




View solution in original post

4 REPLIES 4

sdamiano
Contributor II

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

mickgrant
Contributor III

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
Valued Contributor

@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
New Contributor III

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