Posted on 04-13-2022 12:25 PM
Hi,
I have a script that prompt users to register their Macs to Intune. I would like to run the policy every 60 minutes. What's the best way to get this done ?
Thanks!
Solved! Go to Solution.
04-13-2022 02:30 PM - edited 04-13-2022 03:11 PM
I would do with a script utilizing jamfHelper. Here is my deferral script.
#!/bin/bash
## Script allows the user to defer a number of seconds($TIMER) for a number of tries ($NUMOFTRIES)
## Script has a 60 second timer for the prompt; a ignored answer is taken as a yes and will exit with 0.
## GLOBALS
TIMER=3600 #in seconds
NUMOFTRIES=5
## MESSAGE SCRIPT
ICON="/PATH/TO/PIC.PNG"
SIZE="200"
HEAD="Intune Registration"
DESC="Please click to register... "
for ((i = 0 ; i < $NUMOFTRIES ; i++)); do
DATE=$(date +%Y/%m/%d_%H:%M:%S)
echo "- Counter is $i - $DATE"
## PROMPT DEFERRAL MESSAGE
ANSWER=$(/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Attention" -heading "$HEAD" -icon "$ICON" -iconSize "$SIZE" -description "$DESC" -button1 "Register." -button2 "Do it later." -timeout "60")
echo "---- THE ANSWER was $ANSWER"
## If yes, exit. Else delay for TIMER seconds
if [[ "$ANSWER" == "0" ]]; then
echo "---- Boogalahboo! Do the next phase! Exit 0."
## CODE TO OPEN SELF SERVICE
## CODE CLOSE
exit 0
else
echo "---- Okay. Delaying for $TIMER seconds."
sleep $TIMER
fi
done
if [[ "$i" == $NUMOFTRIES ]]; then
echo "- User deferred $i times. Exit 1."
exit 1
fi
Posted on 04-13-2022 01:28 PM
Are you wanting just a prompt? Or are you wanting them to open Company portal? How will you know when they have completed the registration?
Posted on 04-13-2022 01:43 PM
hi @joshuaaclark, policy is assigned to smart device group. If a user clicks "Register" on prompt it opens self service app for Intune registration. I would like to prompt users every 60 minutes as deadline for managed access control (CA policy) is approaching . Once registration is complete, user won't be part of smart of group.
04-13-2022 02:30 PM - edited 04-13-2022 03:11 PM
I would do with a script utilizing jamfHelper. Here is my deferral script.
#!/bin/bash
## Script allows the user to defer a number of seconds($TIMER) for a number of tries ($NUMOFTRIES)
## Script has a 60 second timer for the prompt; a ignored answer is taken as a yes and will exit with 0.
## GLOBALS
TIMER=3600 #in seconds
NUMOFTRIES=5
## MESSAGE SCRIPT
ICON="/PATH/TO/PIC.PNG"
SIZE="200"
HEAD="Intune Registration"
DESC="Please click to register... "
for ((i = 0 ; i < $NUMOFTRIES ; i++)); do
DATE=$(date +%Y/%m/%d_%H:%M:%S)
echo "- Counter is $i - $DATE"
## PROMPT DEFERRAL MESSAGE
ANSWER=$(/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Attention" -heading "$HEAD" -icon "$ICON" -iconSize "$SIZE" -description "$DESC" -button1 "Register." -button2 "Do it later." -timeout "60")
echo "---- THE ANSWER was $ANSWER"
## If yes, exit. Else delay for TIMER seconds
if [[ "$ANSWER" == "0" ]]; then
echo "---- Boogalahboo! Do the next phase! Exit 0."
## CODE TO OPEN SELF SERVICE
## CODE CLOSE
exit 0
else
echo "---- Okay. Delaying for $TIMER seconds."
sleep $TIMER
fi
done
if [[ "$i" == $NUMOFTRIES ]]; then
echo "- User deferred $i times. Exit 1."
exit 1
fi
Posted on 04-14-2022 07:19 AM
Thanks for sharing script. I appreciate that.
Posted on 04-14-2022 07:25 AM
You can move the variables to the JAMF script numbers to make it more flexible. Adjust the $NUMOFTRIES and $TIMER to what you need. Cool thing is that if Jamf does not get an exit code, it will rerun the policy at next check-in; ie the user reboots during a timer delay.