Need to open app as user via Jamf Policy

KyleEricson
Valued Contributor II

I have tried this script but doesn't seem to work.

#!/bin/zsh

# Get the logged in user's name
CURRENT_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')

# Get the logged in user's id
USER_ID=$(id -un $CURRENT_USER)

# Open app as user
sudo -u $USER_ID open -a 'Jamf Connect.app'

exit 0
Read My Blog: https://www.ericsontech.com
2 REPLIES 2

cbrewer
Valued Contributor II
su -l ${CURRENT_USER} -c "open /Applications/Jamf Connect.app/"

does not like the -c option.