Using Composer to Deploy office with user level preferences

Nicholson
New Contributor

Environment
I have 80 macs, I am using composer to create packages and I am deploying with ARD

Knowledge
I am a PC guy turned math teacher not a mac guy so I do not know anything about mac scripts and was not all that great with PC scripts when I was a full time tech.

What I did
I used the snapshot in composer on a local admin account to create an office package and deployed it with ARD. The good news is it deployed and ran under the standard user. The bad is the user level preferences like (do not run updates) did not install.

What I need
A way to set the user level preferences for all users on the machine (in this case there will be just 1 standard local user, but each mac uses a different name...ie mac1, mac2, mac3...mac80)

My guess is I need to run a post install script that will copy the user level preferences over to the already created mac1...mac80 user. I found cp -p /pathtofilesource /Users/*/Library/Preferences/
But I am guessing I need to run this with some kind of elevated privilege? Can I copy the entire library folder or do I need to make sure I just copy over what MS installed?

Is there an easier way? Can I do this post install and push out using ARD?

Thanks for any help!!!

14 REPLIES 14

bentoms
Release Candidate Programs Tester

Do you have just Conposer or the full suite?

If the later, you can enforce some settings via MCX.

Nicholson
New Contributor

Just composer

Chris_Hafner
Valued Contributor II

Not to speak against composer, but in your situation I would use 'packages'. It allows for much finer control and the packages it creates are far more standard and hence, work a bit better with ARD. Composer allows for better integration with other Casper suite features (such as simple uninstalls of composer created and indexed .dmg's) the preferences your looking for are in ~/Library/Preferences/ though I'll have to look at my scripts to remember exactly what my old tricks were. Office is a little tricky. Someone will likely post an answer before I can get back to my notes...

donmontalvo
Esteemed Contributor III

Nothing against Composer, it's a fine tool...::rollseyes::

Strategy question...why deploy preference files?

Why not use the defaults command?

Do you care that you'll be whacking your users' existing preferences when you overwrite their existing preference files?

Defaults lets you surgically add/remove/change preferences within plist files.

Overwriting preference files is like using a chainsaw to cut off an arm, to cure a sore thumb.

What are you trying to do? :)

+1 on the kudos to Stéphane Sudre for his most excellent Packages.app tool.

Don

--
https://donmontalvo.com

Chris_Hafner
Valued Contributor II

Well said Don, thanks for pointing that out. Don't know what I was thinking!

Nicholson
New Contributor

LOl well as I mentioned I really don't know a whole lot about mac file structure so the terminology I am using is probably not correct. I am open to any solution that solves my problem I was just giving you as much information as possible, :)

I am attempting to deploy 80 mac book airs. I have a local admin account and I have a local standard user account. The users do not have the laptops yet so there is nothing to loose (ATM). I am installing all of the apps that they will need for the year, and I am attempting to touch the machines as little as possible. I can push out packages but the user level configuration does not populate to the standard user. For example, I can take a snapshot, install office, open office and tell it to not perform updates or report to Microsoft, but when I log off and log in as the standard user and open office I am prompted with the same questions. I need to turn updates off because the users will not have the rights to install them.

Hopefully I am making sense

Nicholson
New Contributor

I should clarify..what is the defaults command????

donmontalvo
Esteemed Contributor III

@Nicholson No worries, do a search for "loop script". If you have all the settings you need, you can push them to /tmp on the target Mac, then a postflight script can copy to existing accounts and the User Template.

For defaults...

Open Terminal and type "man defaults" for info on the tool used to manage plist files. There are existing defaults commands for Office, here are a few that I used just the other day for Office 2008 (don't ask!) to disable auto updates, disable setup assistant, and set default save option for Word/Excel/PowerPoint for backward compatibility:

defaults write com.microsoft.autoupdate2 HowToCheck "Manual"
defaults write com.microsoft.office "2008\FirstRun\SetupAssistCompleted" -int 1
defaults write com.microsoft.Word "2008\Default Save\Default Format" "Doc97"
defaults write com.microsoft.Excel "2008\Default Save\Default Format" -int 57
defaults write com.microsoft.Powerpoint "2008\Default Save\Default Save\Default Format" "Microsoft PowerPoint 98 Presentation"

(The above was stolen from various sites, and from William/Steve/Tom/etc...<g>. Damn Microsoft for not giving us a way to set these for all users!)

Different ways to get these commands to the Macs. In your case, you need to be logged on to the Mac as the user you want these settings to be applied to, then push using ARD's UNIX command feature (select "Run command as" your logged in non-admin user).

Since your JAMF Nation profile doesn't say much, I have to ask, does your school already have experienced Mac techs who can handle this for you? If so, they should be able to create a package that uses a combination of launchd and bash to set the above when the user(s) log in, persistently (every time they log in) or once per user.

And since Casper was indeed a friendly ghost...

Ya know, there's always the option to build one MacBook Air the way you like, including customizing the non admin account, capturing the OS with Composer, then using Disk Utility to ASR the image onto the other laptops...old school way, but in your case maybe a viable option? :)

Thanks,
Don

--
https://donmontalvo.com

talkingmoose
Moderator
Moderator

[My reply may be better viewed on the JAMF Nation web site rather than email.]

Many ways to skin a big cat!

Pushing preference files to user home folders is probably the most basic method of creating settings for users. This isn't a bad way of doing things. It's just less efficient. Don't worry about that for now.

Sounds like you've already used Composer to gather your preferences. What you need to understand is you must populate each home folder with these preferences. You can't populate one and expect them to work in the others.

Because your students haven't yet logged in to these machines means you can take advantage of the User Template folder. This folder contains the default set of folders you seen when you create a new user:
- Desktop
- Documents
- Downloads
- Library (hidden)
- Movies
- Music
- Pictures
- Public
- Sites

The Office for Mac preferences you've gathered probably reside in each user home folder here (the tilde refers to the current user's home folder):

~/Library/Preferences

The User Template folder resides here:

/System/Library/User Template/English.lproj

Put your Office preference files in the corresponding location in your package:

System {quote} Library {quote} User Template {quote} English.lproj {quote} Library {quote} Application Support {quote} Microsoft

{/quote}

Preferences {quote} com.microsoft.office.stuff

{/quote}
{/quote}
{/quote}
{/quote}
{/quote}
{/quote}

All new users created afterward will get these settings.

Users {quote} username {quote} Library {quote} Application Support {quote} Microsoft

{/quote}

Preferences {quote} com.microsoft.office.stuff

{/quote}
{/quote}
{/quote}
{/quote}

By the way, putting the user's name into the splash screen isn't really useful for anything. I recommend putting your organization's name in a second time or leaving the user name blank.

Nicholson
New Contributor

@don I was a sysadmin for about 12 years (MCSE, messaging, A+ bla bla)before I changed careers to be a math teacher. I managed a lot of environments remotely using AD. Besides editing some VB scripts or pushing out a printUI script via group policy I do not have much script experience, but I know how things should work in the environment. The school is VERY small...I am the HS math department, so no other mac people. Since I have so many classes to teach I need to centralize management as much as possible. I am doing everything I can to NOT give students admin access to their machines thus the need to make sure any program that wants to turn off auto updates is turned off. the 80 machines I am working on will cover the entire HS student body PLUS all teacher k-12 so I could manually touch all of them if need be but I am looking down the road.

@moose..I am sorry I was not clear. The students do not have the computers yet and have not logged on, but the local username they will use has been created and has been logged into once. could I create a generic post install script that uses a wild card to move the office preference from admin local user to the standard user log in? Something like I posted at the beginning? cp -p /pathtofilesource /Users//Library/Preferences/com.microsoft.office.stuff and
/Users/*/Library/Application Support/Microsoft

donmontalvo
Esteemed Contributor III

Understood, sounds like Williams advice is still valid, maybe a wrapper package with a loop script to populate home directories and User Template would cover your needs. You would drop the stuff in the wrapper, in the right folder structure, then push the package to the Macs. The post-installation script would include a loop to copy the payload to each home directory and set ownership of the payload to each specific user. :)

--
https://donmontalvo.com

daworley
Contributor II

It goes without saying, but this sort of challenge is very common for administrators. That is exactly why the full Casper Suite has standard options to "Fill Existing Users" and "Fill User Template" with files and configurations inside the user home folder.

That said, were I tasked with accomplishing the same sort of task without the Casper Suite, I would agree that a script running a "for loop" with some defaults commands to emulate local MCX would be the right course.

Here is a list of MCX for Microsoft Office:
http://www.officeformachelp.com/office/administration/mcx/

talkingmoose
Moderator
Moderator

Definitely possible to put some smarts into the final package using Composer.

Consider placing the preferences into the User Template as I described. This will take care of future users of the Macs. For those users who already have accounts you can use the following script to copy the files from the User Template into the correct location. The basic command would be:

cp -nR /path/to/source/files /path/to/user/homes

cp = copy
-n = don't replace a file if it already exists (don't overwrite a user's existing preferences)
-R = recursive (applies to folders and subfiles)

A complete script (sans any logging or much error checking) would be something like:

#!/bin/sh

cd /Users
for AUSER in *
do
    if [ "$AUSER" != *(Deleted) -a "$AUSER" != "Shared" ] ; then
        cp -nR /System/Library/User Template/English.lproj/Library/Preferences/com.microsoft.office.* /Users/$AUSER/Library/Preferences
        chown "$AUSER" /Users/$AUSER/Library/Preferences/com.microsoft.office.*
    fi
done

exit 0

The chown line in the script sets the owner of the newly copied files to the user. I've added an if statement to avoid trying to copy these files to the /Users/Shared folder and any potential "/Users/username (Deleted)" folders.

You can still build your package in Composer to install your files into the User Template folder and then add the code above as a Postflight script to run after your files are deployed. In Composer twiddle the disclosure triangle to the left of the package name, right-click Scripts and choose Add Shell Script > Postflight. Paste the script in the right pane replacing the default script.

Save this as a PKG package and not a DMG package. PKG packages can include scripts. DMG packages can't.

Is this the best method for deploying preferences? No. But I believe it's where someone less familiar with the OS X file system and scripting should start. Eventually, I'd suggest looking into Don's idea for using the Defaults command for setting preferences and later looking at a management system like the full Casper suite to input these settings centrally and push them to groups of Macs.

donmontalvo
Esteemed Contributor III

Here's one I cobbled together from borrowed, stolen bits and pieces. In this example your package is named Microsoft-Office2011UserPrefs-1.0 and includes logging...

#!/bin/sh

pathToScript=$0
pathToPackage=$1
targetLocation=$2
targetVolume=$3
PACKAGE="Microsoft-Office2011UserPrefs-1.0"
USERNAME=`dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'
TEMPLATE="/System/Library/User Template/English.lproj/"
TARGETDIR="/Library/Preferences/"
USERPREFS="com.microsoft.office.*"

#-------------------------------------------------------
# Logging
#-------------------------------------------------------
logFile="/private/var/log/$PACKAGE.log"
log () {
echo $1
echo $(date "+%Y-%m-%d %H:%M:%S: ") $1 >> $logFile
}

#-------------------------------------------------------
# Copy user prefs
#-------------------------------------------------------
for U in $USERNAME
do
    log "Copying user prefs to $U directory..."
    /bin/cp -nR $3/$TEMPLATE/$TARGETDIR/$USERPREFS $3/Users/$U/$TARGETDIR
        if [ $? == 0 ]; then
            log "Successfully copied user prefs to $U directory."
        else
            log "Error copying user prefs to $U directory, Exit Code: $?"
            exit 0
        fi
    log "Settting owner of user prefs to $U..."
    /usr/sbin/chown $U $3/Users/$U/$TARGETDIR/$USERPREFS
        if [ $? == 0 ]; then
            log "Successfully set ownership of user prefs to $U."
        else
            log "Error setting ownership of user prefs to $U, Exit Code: $?"
            exit 0
        fi
done

#-------------------------------------------------------
# Exit
#-------------------------------------------------------
log "Goodbye."

exit 0      ## Success
exit 1      ## Failure

[EDIT: Fixed a couple syntax errors...please test before implementing. :) ]

HTH
Don

--
https://donmontalvo.com