Posted on 10-28-2015 05:21 AM
Looking for a new script that I can run on log in to update username status in Casper.
Thanks
Solved! Go to Solution.
Posted on 10-28-2015 05:35 AM
We use the below script to update the username. This script runs weekly once between 10AM - 12PM and 2PM-4PM. This will not run recon or update the username if the machine is in login screen.
#!/bin/sh
# Script to report the Username if users logged in
# Created by Karthikeyan Marappan on 10/21/2015
loggedInUser=$( ls -la /dev/console | cut -d " " -f 4 )
if [[ $loggedInUser != root ]];
then
/usr/sbin/jamf recon -endUsername $loggedInUser
else
echo "Login Screen, No user logged in"
fi
exit 0
Thanks & Regards,
Karthikeyan
Posted on 10-28-2015 06:42 AM
Here's the one we use that's tied to a policy that runs at login. It only updates the username if the user logging in is not root or one of the local admins.
#!/bin/sh
# Script to set the username in the Location information of a computer detail record on the JSS.
# This script will only update the username if the logged in user is not root or any user with admin in the name.
# 7/2/13 - Jehan B Aziz
thisUser=`stat -f '%u %Su' /dev/console | awk '{ print $2 }'`
if [ $thisUser = "root" ]; then
exit
elif [[ $thisUser == *admin* ]]; then
exit
else
jamf recon -endUsername $thisUser
fi
exit 0
Posted on 10-28-2015 05:35 AM
We use the below script to update the username. This script runs weekly once between 10AM - 12PM and 2PM-4PM. This will not run recon or update the username if the machine is in login screen.
#!/bin/sh
# Script to report the Username if users logged in
# Created by Karthikeyan Marappan on 10/21/2015
loggedInUser=$( ls -la /dev/console | cut -d " " -f 4 )
if [[ $loggedInUser != root ]];
then
/usr/sbin/jamf recon -endUsername $loggedInUser
else
echo "Login Screen, No user logged in"
fi
exit 0
Thanks & Regards,
Karthikeyan
Posted on 10-28-2015 06:20 AM
There might be a simpler method by creating a script that uses the $3 variable in a policy. When is the script supposed to run? What exactly are you trying to accomplish? You may get a lot of different answers depending on what you want to do none of which may help you with your end goal.
Posted on 10-28-2015 06:33 AM
Pretty much I want to update the names in Casper, and Casper remote to the correct computer.
Posted on 10-28-2015 06:42 AM
Here's the one we use that's tied to a policy that runs at login. It only updates the username if the user logging in is not root or one of the local admins.
#!/bin/sh
# Script to set the username in the Location information of a computer detail record on the JSS.
# This script will only update the username if the logged in user is not root or any user with admin in the name.
# 7/2/13 - Jehan B Aziz
thisUser=`stat -f '%u %Su' /dev/console | awk '{ print $2 }'`
if [ $thisUser = "root" ]; then
exit
elif [[ $thisUser == *admin* ]]; then
exit
else
jamf recon -endUsername $thisUser
fi
exit 0
Posted on 10-28-2015 06:49 AM
I use this for any account that logs in. Set as an ongoing login policy.
if [ -z $3 ]; then currentUser=stat -f '%Su' /dev/console
; else currentUser=$3; fi; jamf recon -endUsername $currentUser