Jamf policy frequency every hour

ysdevgan
Contributor

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!

1 ACCEPTED SOLUTION

joshuaaclark
Contributor

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

 

 

View solution in original post

5 REPLIES 5

joshuaaclark
Contributor

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?

 

ysdevgan
Contributor

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.

joshuaaclark
Contributor

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

 

 

Thanks for sharing script. I appreciate that. 

joshuaaclark
Contributor

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.