@Macuser1810 Here's basic code to get you started. I don't know what you were displaying in the message, so the jamfHelper part of this is left very generic. You can update it with your own code. But the rest should be ok to use as is. Test it out and see if it does what you want.
Script example:
#!/bin/zsh
## Path to jamfHelper executable
JAMF_HELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
## This is our starting counter value. This gets placed into the plist file on first run under any account
START_VALUE="1"
## Maximum number of times the message should be displayed before stopping
MAX_VALUE="10"
## Get the current logged in user
LOGGED_IN_USER=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");' | sed '/^$/d')
## Set the path to the counter file for the current user
COUNTER_FILE="/Users/$LOGGED_IN_USER/Library/Preferences/com.company.messagecounter.plist"
## Create the initial counter plist file if it's not already present, and set the current count value to 1, or
## if the counter file exists, grab the value from it
if [ ! -e "$COUNTER_FILE" ]; then
/usr/bin/defaults write "$COUNTER_FILE" displayCount -int "$START_VALUE"
CURRENT_VALUE="$START_VALUE"
else
CURRENT_VALUE=$(/usr/bin/defaults read "$COUNTER_FILE" displayCount)
fi
if [ "$CURRENT_VALUE" -lt "$MAX_VALUE" ]; then
## Display the jamfHelper message here.
## Message gets pushed to the background so it doesn't hang up the script.
## Replace placeholder text strings below or use your own jamfHelper message code
"$JAMF_HELPER"
-windowType utility
-title "Title"
-heading "Heading"
-description "Description"
-button1 "OK"
-defaultButton 1 &
## Update the count and replace the value in the plist
NEW_VALUE=$((CURRENT_VALUE+1))
/usr/bin/defaults write "$COUNTER_FILE" displayCount -int "$NEW_VALUE"
else
echo "The counter value is ${CURRENT_VALUE}, so we are no longer displaying the message"
fi
I trust you're ok with putting this into a policy and setting it to the login trigger and ongoing frequency, which would be the other half of this.
One thing to test out is to make sure it actually runs at login. If your Macs connect to Wi-Fi like most, there's a possibility that the network connection isn't active at login time and the policy may not actually run. There are some workarounds to that, such as deploying this as an offline policy for example.