Posted on 04-08-2020 09:10 AM
I would appreciate some assistance to why my policy is failing. I have verified a user was logged in and clicked the proper button. Here are the details.
I created a script that calls my variable for 'loggedInUser' to open Self Service to view a specific policy. Issue is for some of my users when they select migrate nothing happens. When I look at the JAMF history log of the policy, I get the error: Script exit code: 1
Script result: User clicked MIGRATE; now directing user to Self Service Policy.
open requires the user to be logged in at the console to launch applications.
Error running script: return code was 1.
I have attempted grabbing the variable for loggedInUser two separate ways. Both give me mixed results. Some users give me no problem and some give me the above error.
stat -f%Su /dev/console
ls -l /dev/console | awk '{print $3}'
Script #1
#!/bin/bash
loggedInUser=$(stat -f%Su /dev/console)
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
windowType="hud"
description="There is a critical AntiVirus update available for your company issued computer. To perform the Migration, select 'Migrate' below and you will be re-directed to Self Service. If you are unable to perform this update at the moment, please select 'Cancel' to be prompted again tomorrow.
*Please quit open applications and save all working documents before selecting 'Migrate.'
*Installing now?
Select 'Migrate' below --> Select 'Migrate' in the Self Service window when you are ready to Migrate to Microsoft Defender ATP. This update can take upwards of 15 minutes.
*Want to Migrate on your own time?
Navigate to Self Service --> Search for ATP --> Select Migrate
button1="Migrate"
button2="Cancel"
icon="/Library/Application Support/JAMF/JamfCustomApps/Company_logo.png"
title="Critical: AntiVirus Update Available"
alignDescription="left"
alignHeading="center"
defaultButton="2"
timeout="900"
# JAMF Helper window as it appears for targeted computers
userChoice=$("$jamfHelper" -windowType "$windowType" -lockHUD -title "$title" -timeout "$timeout" -defaultButton "$defaultButton" -icon "$icon" -description "$description" -alignDescription "$alignDescription" -alignHeading "$alignHeading" -button1 "$button1" -button2 "$button2")
# If user selects "MIGRATE"
if [ "$userChoice" == "0" ]; then
echo "User clicked MIGRATE; now directing user to Self Service Policy."
sudo -u $loggedInUser open 'jamfselfservice://content?entity=policy&id=7829&action=view'
# If user selects "Cancel"
elif [ "$userChoice" == "2" ]; then
echo "User clicked Cancel or timeout was reached; now exiting."
exit 0
fi
Script #2
#!/bin/bash
loggedInUser=$(ls -l /dev/console | awk '{print $3}')
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
windowType="hud"
description="There is a critical Antivirus update available for your Company issued computer. To perform the Migration, select 'Migrate' below and you will be re-directed to Self Service. The migration will take approximately 10 minutes.
If you do not have time to Migrate you can always click on Cancel, however you will be prompted daily until the install has been completed.
*Want to Migrate on your own time?
Navigate to Self Service --> Search for ATP --> Select Migrate
button1="Migrate"
button2="Cancel"
icon="/Library/Application Support/JAMF/JamfCustomApps/Company_logo.png"
title="Critical: Antivirus Update Available"
alignDescription="left"
alignHeading="center"
defaultButton="2"
timeout="900"
# JAMF Helper window as it appears for targeted computers
userChoice=$("$jamfHelper" -windowType "$windowType" -lockHUD -title "$title" -timeout "$timeout" -defaultButton "$defaultButton" -icon "$icon" -description "$description" -alignDescription "$alignDescription" -alignHeading "$alignHeading" -button1 "$button1" -button2 "$button2")
# If user selects "MIGRATE"
if [ "$userChoice" == "0" ]; then
echo "User clicked MIGRATE; now directing user to Self Service Policy."
sudo -u $loggedInUser open 'jamfselfservice://content?entity=policy&id=7829&action=view'
# If user selects "Cancel"
elif [ "$userChoice" == "2" ]; then
echo "User clicked Cancel or timeout was reached; now exiting."
exit 0
fi
Posted on 08-11-2020 07:24 AM
I have the same problem
Posted on 08-11-2020 07:32 AM
Why are you directing to Self Service instead of running a policy on a custom event or ID? They agreed; just install it.
#!/bin/sh
#sudo -u $loggedInUser open 'jamfselfservice://content?entity=policy&id=7829&action=view'
#pkill $processName
jamf policy -id 7829 #or whatever policy to run the install