Posted on 08-01-2023 08:38 AM
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?
Solved! Go to Solution.
08-01-2023 09:14 AM - edited 08-01-2023 09:15 AM
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)
Posted on 08-01-2023 08:50 AM
does this work?
/usr/bin/stat -f%Su
Posted on 08-01-2023 09:08 AM
Not through Jamf because Jamf runs as root
08-01-2023 09:14 AM - edited 08-01-2023 09:15 AM
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)
Posted on 08-01-2023 09:26 AM
This worked, thank you!
Posted on 08-08-2023 11:21 PM
Thank you, it worked for me too.