Skip to main content

I am writing a quick script to delete a file from our users computers. We have Jamf Connect on all computers currently.

I'm using this script to get the logged in user:

loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name 😕 && ! /loginwindow/ { print $3 }' )

This used to work for us but now that we are on Jamf Connect it just shows the IDP user, not the local user. I need the local user in the variable because that is actually where Documents are stored for the user.

Any way to extract the actual Local account that the user is logged into and avoid the IDP user?

does this work? 

/usr/bin/stat -f%Su


does this work? 

/usr/bin/stat -f%Su


Not through Jamf because Jamf runs as root


Not through Jamf because Jamf runs as root


Yes... that was more to test the result returned is what you were after.. I use this in JAMF scripts.. and it works?

localuser$(/usr/bin/stat -f%Su /dev/console)


Yes... that was more to test the result returned is what you were after.. I use this in JAMF scripts.. and it works?

localuser$(/usr/bin/stat -f%Su /dev/console)


This worked, thank you!


Yes... that was more to test the result returned is what you were after.. I use this in JAMF scripts.. and it works?

localuser$(/usr/bin/stat -f%Su /dev/console)


Thank you, it worked for me too.


Reply