Posted on 09-15-2011 07:35 AM
I use Launch Agent and works well for all new and existing users. I have packaged all below as .pkg. You can send it using Policy, Remote, locally or ARD or from build point.
1 - you will need to load using launchctl command as postflight script
#!/bin/sh
## postflight
launchctl load /Library/LaunchAgents/com.bskyb.Office11MeSettings.plist
exit 0 ## Success
exit 1 ## Failure
2 - I use this script with Launch Agent. Put the script in to /Library/Scripts/personalizeoffice.sh or your preferred location, but make sure change it from the plist in section 3
#!/bin/bash
#declare the variables. Macs binding to AD.
username=whoami
firstname=dscl . -read /Users/$username RealName | awk ' NR > 1 {print $2}'
lastname=dscl . -read /Users/$username RealName | awk ' NR > 1 {print $1}' | tr -d ','
#use PlistBuddy to set the value based on the earlier declared variables
/usr/libexec/PlistBuddy -c "set :14\UserInfo\UserName '$firstname' '$lastname'" ~/Library/Preferences/com.microsoft.office.plist
#this script is called by a LaunchAgent so I really don't want to know about it or inform the user in labs even if it fails
exit 0
3 - Here is the Launch Agent plist file goes in /Library/LaunchAgents
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>us.in.k12.lsc.PersonalizeOffice</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Scripts/personalizeoffice.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
I hope this helps
Cem
Posted on 09-15-2011 07:36 AM
I am a scripting noob, but started writing a similar script this week after our jump start. com.microsoft.office.plist appears to only set the display name on the application splash screens. The strings in ~/Documents/Microsoft User Data/Office 2011 Identities/MeContact.plist is used to set the user information in each app which is what will be saved to files created by that user.
What I have so far (clients company name is hard coded, but removed in here):
#!/bin/sh
firstname=finger $LOGNAME | awk '/Name: / {print $4}'
lastname=finger $LOGNAME | awk '/Name: / {print $5}'
firstinitial=echo $firstname | cut -c 1
lastinitial=echo $lastname | cut -c 1
defaults write com.microsoft.office "14UserInfoUserName" -string "$firstname $lastname"
defaults write "/Users/$LOGNAME/Documents/Microsoft User Data/Office 2011 Identities/MeContact.plist" "First Name" -string $firstname
defaults write "/Users/$LOGNAME/Documents/Microsoft User Data/Office 2011 Identities/MeContact.plist" "Last Name" -string $lastname
defaults write "/Users/$LOGNAME/Documents/Microsoft User Data/Office 2011 Identities/MeContact.plist" Name -string "$firstname $lastname"
defaults write "/Users/$LOGNAME/Documents/Microsoft User Data/Office 2011 Identities/MeContact.plist" Initials -string $firstinitial$lastinitial
defaults write "/Users/$LOGNAME/Documents/Microsoft User Data/Office 2011 Identities/MeContact.plist" "Business Company" -string "Your Company"
One problem I found w/ finger is that our AD display names are "Last, First" and the comma makes the first name move to the office field. I am going to try and re-write it using dscl and also add logic for users with 2 name last names.
--
Brian Goldstein
Singer Consulting, Inc.
brian at randsinger.com
888.222.2959 x2103
Posted on 09-15-2011 07:43 AM
Careful running scripts in Casper with whomai, finger, who and last, since Casper runs all scripts as root. There are better methods of detection users, and depending on your OS/image model you can do it many ways.
Posted on 09-15-2011 07:50 AM
Yeah but this script will run with Launch Agent for the logged in user….anyway its good that you have pointed out, if anybody just wanted the script bit.
Posted on 09-15-2011 08:01 AM
Yup, totally another way to do it. Launch Agents, in the user's home
folder will run as that user, or launch agents that run at log in also
run as every user when they log in, you can also use log in hooks to
grab currently logged in users, while launch daemons run as root.
Another method is by UID. We all know that all
local/network/portable/AD users have a UID greater than 500, and if you
created your local admin accounts with a UID of less than 500 to hide
them like me, you can simply do this:
dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'
This will generate a list of every user on the machine that has a UID
of greater than 500 and you can simply loop through it.
-Tom