Posted on 11-24-2010 09:32 AM
I wanted to post this for others if they are interested. I think I took a
script that someone else posted (Tom maybe?) and modified it. The earlier
script used a dscl Users listing before to extract the
First and Last name to populate those fields. The problem I had with the
other script was that the RealName was populating with multiple user
accounts on multi user systems. So the JSS was displaying a whacked out
Combo of multiple first and lastnames. Here is what I came up with. Thanks
to all those who gave me an idea for this.
Takes the shortname of currently logged in user (set to run at login) - I
have it set to run once a day. BTW - notice that we are using AD so make
sure to modify for your directory preference...
#!/bin/sh
# Grab currently logged in user shortname
sName=ls -l /dev/console | awk '{ print $3 }'
fullName=`dscl /Active Directory/<yourdomainhere> -read /Users/$sName RealName | grep -v RealName`
# Recon machine and update JSS
jamf recon -realname "$fullName" -endUsername $sName
If you prefer for use in other scripting you can change the $fullName variable to extract the firstName and lastName by using the following....
fName=`dscl /Active Directory/<yourdomainhere> -read /Users/$sName
RealName | grep -v RealName | awk '{ print $1 }'`
lName=`dscl /Active Directory/<yourdomainhere> -read /Users/$sName
RealName | grep -v RealName | awk '{ print $2 }'`
Enjoy! And Happy Thanksgiving to all!
spike
More teams and higher stakes make PUNKIN CHUNKIN 2010 too big for one network! MYTHBUSTERS’ own Adam Savage & Jamie Hyneman host the explosive, gooey fun as PUNKIN CHUNKIN takes flight Thanksgiving Day at 8PM (ET/PT) on a special Discovery Channel and Science Channel simulcast. THE ROAD TO PUNKIN CHUNKIN airs on Science Channel Wednesday, November 24 at 10PM (ET/PT).