Thursday, January 27, 2011

Deploy Photoshop Elements 9 Trial with SCCM

Here is just a quick instruction on how to install Photoshop Elements 9 Trial silent with SCCM. Since it's Adobe, it wasn't as easy as you would hope.

Anyway...

First, deploy Adobe Application Manager 1.5:
"Setup.exe --mode=silent"
Second, deploy Adobe Photoshop Elements 9 and Elements Organizer with a Task Sequence.
msiexec /i "Adobe Photoshop Elements 9.msi" TRANSFORMS=1033.mst ELEMENTS_EN_US=1 ORGANIZER_EN_US=1 DISABLEEMSFEATURES=1 DISABLEOLSFEATURES=1 WATCHSERVICE=0 NOT_STANDALONE=1 /qn /norestart

msiexec /i "Elements 9 Organizer.msi" TRANSFORMS=1033.mst NOT_STANDALONE=1 /qn /norestart
Why not deploy AAM in the Task Sequence? It did not work (for me anyway...), the logs said it all went fine, but it didn't. So you have to deploy AAM as a regular program separately.

Thursday, January 20, 2011

Fully automated reinstall of computer lab

We have a computer room with 23 iMacs, all is dual boot Mac OS X 10.6/Windows 7 through BootCamp. Here is how I have automated the whole process.









Because there are so many applications in both OS's, we have created two master images which is deployed through DeployStudio (DSS).

DeployStudio does the following:

- Deploys the two master images
- Sets the computer name from the DSS database in both Mac OS and Windows
- Sets Mac OS as default startup disk
- Sets time server in Mac OS
- Joins Mac OS to our Active Directory
- Activates Software Update on first boot
- Activates a script on first boot that sets some energy savings settings
- Activates a script on first boot that sets the windows partition as default startup disk

So when DSS is done, rebooted and run Software Update, joined AD and run the scripts, it boots into a syspreped Windows 7 installation. The sysprep does a lot of things to the Windows installation, like: setting the computername, joining AD (through a powershell script on first automatic login), running winsat and so on...

One thing to think about is when you create the unattend.xml, you have to specify a ComputerName, otherwise, that key is not present in the xml file, and DSS does not set the ComputerName automatically.

And another thing to think about is the joining to AD. The component UnattendedJoin, did not work for us, then I discovered we were not alone. Setting the admin user to login automatically one time and setting a powershell script to run on first login did the trick.

So long fully automated, but you still have to go to every machine and netboot them, select workflow in DSS and trigger it. Here is where bless blesses us! But first we had to create a user and a group for DSS, which we named dsautodeploy and dsautodeployers. Add the group as a runtime group in DSS, create a NetBoot set in DSS with dsautodeploy enabled as autologin. Then edit the workflow in DSS so everything is automated and select a default workflow for the group of computers.
Now, all you have to do to reinstall the computers is to send this command with ARD (as root):

bless --netboot --server "bsdp://" --options "rp=nfs::/private/tftpboot/NetBoot/NetBootSP0:.nbi/DeployStudioRuntime.sparseimage"

And if the computers is booted in Windows 7, you can (as of BootCamp 3.0) run this command with psexec:
psexec \\COMPUTERNAME "C:\Program Files\Boot Camp\BootCamp.exe" -startupDisk

And then run the bless command above. The "BootCamp.exe -startupDisk" command may also be used in sysprep to boot into Mac OS after the windows setup is done when deploying. But we want windows to be the default OS on these machines...

The script I run in the workflow to make Windows the default startup disk is as simple as this:

#!/bin/sh

#Find the Windows disk and it's mountpoint
WINDOWSDISK=$(mount | grep ntfs | awk -F" " '{print $3}')

#Set $WINDOWSDISK as default boot partition
bless --mount "$WINDOWSDISK" --setBoot --legacy --verbose

exit 0

Happy deploying!

PS. Don't you just love DSS? I know I do :)

Tuesday, November 2, 2010

Get rid of Office 2011's First Run Wizard

I made a similar script like this for Office 2008, but Microsoft changed some things in Office 2011 and how it determines if First Run Wizard is run.
It seems like the Office apps looks at three files and certain settings in them, these files are:

~/Library/Preferences/com.microsoft.office.plist
~/Library/Preferences/com.microsoft.autoupdate2.plist
~/Library/Preferences/com.microsoft.error_reporting

The file "com.microsoft.office.plist" must contain:
- The key "14\FirstRun\SetupComplete" with value "1" (-int)

The file "com.microsoft.autoupdate2.plist" must contain:
- The key "HowToCheck" with value "Manual" (-string) (if you don't want it to check automatically)
- The key "LastUpdate" with value "2001-01-01T00:00:00Z" (-date)

The file "com.microsoft.error_reporting must contain:
- The key "SQMReportsEnabled" with value "False" (-bool)
- The key "ShipAssertEnabled" with value "False" (-bool)

And as an optional thing, in the script below, I added a function that sets the user's name in "com.microsoft.office.plist".

Pardon me for the lack of comments in the script below, but I think you understand it :)

Provided "as is"...

#!/bin/bash

# Loginhook to get rid of Office First run.
# This version is for Office 2011
# Updated 101102 by Marcus Jaensson

##### NOTES ABOUT FILE PERMISSIONS ######
# Setting rights to 777 as chown does not seem to work as expected in a loginhook
# It seems that Office sets the correct owner on the files when launching an Office-app
# Really no secrets in these files anyway...



# Install this:
# 1. Copy this to /Library/Scripts/loginhook.sh
# 2. Set owner to root and chmod 755
# 3. sudo defaults write com.apple.loginwindow LoginHook /Library/Scripts/loginhook.sh

LOGF="/tmp/loginhook.log"

OFFICEPREF="/Users/$1/Library/Preferences/com.microsoft.office.plist"
OFFICEDOMAIN="/Users/$1/Library/Preferences/com.microsoft.office"

AUPREF="/Users/$1/Library/Preferences/com.microsoft.autoupdate2.plist"
AUDOMAIN="/Users/$1/Library/Preferences/com.microsoft.autoupdate2"

ERPREF="/Users/$1/Library/Preferences/com.microsoft.error_reporting.plist"
ERDOMAIN="/Users/$1/Library/Preferences/com.microsoft.error_reporting"


echo "##### Beginning Log #####" >> $LOGF
echo `date "+%y%m%d %H.%M"` >> $LOGF
echo "User: $1" >> $LOGF


# Create files and values com.microsoft.office.plist
if [ -f "$OFFICEPREF" ]
then
echo "com.microsoft.office.plist exists." >> $LOGF
echo "Checking if 14\\FirstRun\\SetupComplete has value 1" >> $LOGF
SETUPSTATUS=$(defaults read "$OFFICEDOMAIN" "14\\FirstRun\\SetupComplete")
if [ $SETUPSTATUS = 1 ]
then
echo "SetupComplete is set to 1. Nothing to do" >> $LOGF
else
echo "Setting SetupComplete to 1" >> $LOGF
defaults write "$OFFICEDOMAIN" "14\\FirstRun\\SetupComplete" -int 1
chmod -f 777 "$OFFICEPREF"
fi
else
echo "com.microsoft.office.plist does not exist. Creating it and setting SetupComplete to 1" >> $LOGF
defaults write "$OFFICEDOMAIN" "14\\FirstRun\\SetupComplete" -int 1
chmod -f 777 "$OFFICEPREF"
fi

# Create fields and values com.microsoft.autoupdate2.plist
if [ -f "$AUPREF" ]
then
echo "com.microsoft.autoupdate2.plist exists." >> $LOGF
echo "Checking if HowToCheck has value Manual" >> $LOGF
HOWTOCHECK=$(defaults read "$AUDOMAIN" "HowToCheck")
LASTUPDATE=$(defaults read "$AUDOMAIN" "LastUpdate")
if [ $HOWTOCHECK = "Manual" ]
then
echo "HowToCheck is set to Manual. Nothing to do" >> $LOGF
else
echo "Setting HowToCheck to Manual" >> $LOGF
defaults write "$AUDOMAIN" "HowToCheck" -string "Manual"
chmod -f 777 "$AUPREF"
fi
if [ -z "$LASTUPDATE" ]
then
echo "LastUpdate is empty, populating"
defaults write "$AUDOMAIN" "LastUpdate" -date "2001-01-01T00:00:00Z"
else
echo "LastUpdate exists"
fi
else
echo "com.microsoft.autoupdate2.plist does not exist. Creating it and setting HowToCheck and LastUpdate to Manual" >> $LOGF
defaults write "$AUDOMAIN" "HowToCheck" -string "Manual"
defaults write "$AUDOMAIN" "LastUpdate" -date "2001-01-01T00:00:00Z"
chmod -f 777 "$AUPREF"
fi

# Create fields and values com.microsoft.error_reporting.plist
if [ -f "$ERPREF" ]
then
echo "com.microsoft.error_reporting.plist exists." >> $LOGF
echo "Checking if SQMReportsEnabled has value False" >> $LOGF
SQMREPORTS=$(defaults read "$ERDOMAIN" "SQMReportsEnabled")
SHIPASSERT=$(defaults read "$ERDOMAIN" "ShipAssertEnabled")
if [ $SQMREPORTS = "0" ]
then
echo "SQMReportsEnabled is set to False. Nothing to do" >> $LOGF
else
echo "Setting SQMReportsEnabled to False" >> $LOGF
defaults write "$ERDOMAIN" "SQMReportsEnabled" -bool False
chmod -f 777 "$ERPREF"
fi
if [ $SHIPASSERT = "0" ]
then
echo "ShipAssertEnabled is set to False. Nothing to do" >> $LOGF
else
echo "Setting ShipAssertEnabled to False" >> $LOGF
defaults write "$ERDOMAIN" "ShipAssertEnabled" -bool False
chmod -f 777 "$ERPREF"
fi
else
echo "com.microsoft.error_reporting.plist does not exist. Creating it and setting SQMReportsEnabled and ShipAssertEnabled to False" >> $LOGF
defaults write "$ERDOMAIN" "SQMReportsEnabled" -bool False
defaults write "$ERDOMAIN" "ShipAssertEnabled" -bool False
chmod -f 777 "$ERPREF"
fi


# Set name
REALNAME=$(dscl . -read /Users/$1 RealName | grep -v RealName | sed 's/^[ ]*//')
echo "RealName is $REALNAME" >> $LOGF
REALNAMESTATUS=$(defaults read "$OFFICEDOMAIN" "14\\UserInfo\\UserName")
echo "RealName Status is $REALNAMESTATUS" >> $LOGF
if [ -z "$REALNAMESTATUS" ]
then
echo "Setting realname" >> $LOGF
defaults write "$OFFICEDOMAIN" "14\\UserInfo\\UserName" -string "$REALNAME"
chmod -f 777 "$OFFICEPREF"
else
echo "REALNAME is already set" >> $LOGF
fi

echo -e "---------- Ending Log ----------\n" >> $LOGF

exit 0

Monday, October 25, 2010

Change default keyboard layout for loginwindow

We discovered that a system restore image we used to deploy new Macs with had the wrong keyboard layout at the loginwindow. If you change the keyboard layout in the Accounts PrefPane, it just affects the currently logged in user.
Apples solution to this is either to reinstall Mac OS X or select to show the input menu in the loginwindow, this is two solutions that I can't accept, so I started digging and found a solution!

The settings are stored in /Library/Preferences/com.apple.HIToolbox.plist and changing these solved my problem.

Here is quick and dirty script to change the default keyboard layout to Swedish:


#!/bin/bash

# This will set default keyboard language to Swedish.

# Path to plist file
PLISTDOMAIN="/Library/Preferences/com.apple.HIToolbox.plist"

# Path to PlistBuddy
PB="/usr/libexec/PlistBuddy"

"$PB" -c "set :AppleDefaultAsciiInputSource:KeyboardLayout\ ID 7" "$PLISTDOMAIN"
"$PB" -c "set :AppleDefaultAsciiInputSource:KeyboardLayout\ Name Swedish\ -\ Pro" "$PLISTDOMAIN"
"$PB" -c "set :AppleCurrentKeyboardLayoutInputSourceID com.apple.keylayout.Swedish-Pro" "$PLISTDOMAIN"
"$PB" -c "set :AppleEnabledInputSources:0:KeyboardLayout\ ID 7" "$PLISTDOMAIN"
"$PB" -c "set :AppleEnabledInputSources:0:KeyboardLayout\ Name Swedish\ -\ Pro" "$PLISTDOMAIN"

exit 0

Tuesday, October 19, 2010

Create mobile account for two different users with the same name fails

We discovered this today, and we haven't found any information about it anywhere, so...

If you have a mac bound to an Active Directory where there are users with the same name but different usernames, you may see that certain users cannot login to the mac. This happens when you have "Create mobile account at login" activated and a user tries to login who has the same name as a previously logged in user.

What is going wrong then? I don't know exactly, besides that it's the "RecordName" key that is the problem. There cannot be two users in the local database that has a value in RecordName matching any other user's value in RecordName.

If you change the value to something else on the first user, the second user can login.

Delete the value:
sudo dscl . delete /Users/uname1 RecordName "John Doe"

Append a new value:
sudo dscl . append /Users/uname1 RecordName "John Marc Doe"

Or simply change:
sudo dscl . change /Users/uname1 RecordName "John Doe" "John Marc Doe"

UPDATE 2010-10-20
I made a bugreport to Apple regarding this yesterday and got a response that they need logs. I will upload the logs today to Apple and then we'll see what they have to say about it...

UPDATE 2010-10-25
Apple says this is expected behavior. I have replied that I disagree.

Wednesday, September 22, 2010

Convert movies to iPhone friendly format with ffmpeg on a Mac

I wanted to make a bash script that parsed a given directory for movie files and then made them into an iPhone friendly format. In this script I use HandBrakeCLI and ffmpeg.

HandBrakeCLI is a no-brainer to install, just download the binary and run it, but ffmpeg is a bit harder to get working, so here are a brief and "technical" instruction on how I succeeded. Apple Developer Tools is required!

1. mkdir ~/source
2. cd ~/source

3. cvs -d:pserver:anonymous@lame.cvs.sourceforge.net:/cvsroot/lame login (press enter when asked for passwd)
4. cvs -z3 -d:pserver:anonymous@lame.cvs.sourceforge.net:/cvsroot/lame co -P lame
5. cd lame
6. ./configure
7. make
8. sudo make install

9. cd ~/source
10. cvs -d:pserver:anonymous@faac.cvs.sourceforge.net:/cvsroot/faac login
11. cvs -z3 -d:pserver:anonymous@faac.cvs.sourceforge.net:/cvsroot/faac co -P faac
12. cd faac
13. ./configure
14. make
15. sudo make install

16. cd ~/source
17. svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
18. cd ffmpeg
19. ./configure --enable-libmp3lame --enable-shared --disable-mmx --arch=x86_64 --enable-libfaac --enable-gpl --enable-nonfree --enable-avfilter --enable-postproc
20. make
21. sudo make install


And now, when you're done, you can convert movies to mp4 that is 480px wide and keeping the aspect ratio. This is what I use, found bits here and there and put it together to this:

ffmpeg -i INPUT.avi -acodec libfaac -ac 2 -vcodec mpeg4 -vf "scale=480:-1" -b 1000k -ab 128k -coder 1 -flags +aic+cbp+loop+mv4+naq -trellis 1 OUTPUT.mp4

I'm using ffmpeg SVN-r25157, Lame 3.98.4 and faac 1.28 on Mac OS X 10.6.4. If you download and compile the standard ffmpeg 0.6, the "-vf "scale=480:-1" bit will not work. So download the latest through cvs.

This is more or less a rip off of the instruction at stephenjungels.com. In the latest svn of ffmpeg, there is no support for faad, so I left that bit out.

This instruction is available "as is". I will not answer any questions about "How do I do this and that?"

Wednesday, September 1, 2010