Attempt at building Sysprep’d VM with Server 2008, SQL 2008, MOSS

In the past I have followed excellent article on how to build a sysprep’d moss vm – I wanted to do the same with all of the latest Microsoft products on Windows Server 2008, but I could not apply the everything from the quoted article, as sysprep for server 2008 now uses an answerfile. Note that sysprep is now also included as part of windows server 2008.  Note that I am still having a few issues getting this working – namely that I cannot start the osearch service via stsadm until I reboot (hence a cannot run the first logon script automatically from sysprep). This is discussed further below.

Building VM Prior to Sysprep

  1. Using Virtual PC 2007,  I created a new virtual machine with Windows Server 2008 Enterprise as the host operating system
  2. I then installed the following software (you can choose what you want to install as long as SQL is present): Microsoft Office Ultimate (includes infopath), Scite 1.5.7, Firefox, IE Developer Toolbar, .NET 3.5 Framework, SQL Server 2008 Enterprise, MOSS Enterprise with SP1, Visual Studio 2008, Visual Studio 2008 Team Explorer, Flash plugin, Adobe reader, Silverlight 2.0, Expression Blend 2, Expression Web 2, Sharepoint Designer + SP1, Fiddler
  3. I then installed MOSS Enterprise with SP1, but did not run the configuration wizard.  IT IS CRUCIAL NOT TO RUN THIS BEFORE SYSPREP.
  4. For convenience, I added C:\Program Files\Common Files\Microsoft Shared\Web Server Extension\12\bin to the path environment variable.
  5. As sysprep removes all users from SQL, except from builtin\administrators and the sa account, and security is left as windows integrated, I gave the builtin\administrators group sysadmin rights via SQL Server Enterprise Manager (otherwise you will not be able to create new databases etc after sysprep).

Building Unattend Answer File

I then built an answerfile to be used by sysprep using Microsoft Windows AIK for Windows Server 2008. To do this, I created another VM using Windows Server 2008 Enterprise and installed Microsoft Windows AIK on it. You could simple just create an answerfile using a text / xml editor if you wanted, as long as you ensure its structure is correct. My resultant answerfile is relatively simple and is as follows:

<?xml version=”1.0″ encoding=”utf-8″?>
<unattend xmlns=”urn:schemas-microsoft-com:unattend”>
    <settings pass=”windowsPE”>
        <component name=”Microsoft-Windows-Setup” processorArchitecture=”x86″ publicKeyToken=”31bf3856ad364e35″ language=”neutral” versionScope=”nonSxS” xmlns:wcm=”” xmlns:xsi=””>
                <FullName>Robert Nowik</FullName>
    <settings pass=”oobeSystem”>
        <component name=”Microsoft-Windows-Shell-Setup” processorArchitecture=”x86″ publicKeyToken=”31bf3856ad364e35″ language=”neutral” versionScope=”nonSxS” xmlns:wcm=”” xmlns:xsi=””>
                <SynchronousCommand wcm:action=”add”>
                    <CommandLine>C:\sysprep\mossconfig.bat %COMPUTERNAME%\%USERNAME% %USERNAME%@%COMPUTERNAME% %COMPUTERNAME%\%USERNAME% password
                    <Description>Setup Moss</Description>
    <cpi:offlineImage cpi:source=”wim:c:/users/administrator/desktop/install.wim#Windows Longhorn SERVERENTERPRISE” xmlns:cpi=”urn:schemas-microsoft-com:cpi” />

Note that the most important call if the FirstLogonCommand that calls a batch file (that more or less corresponds with that from the following article Note that the password used is the only hardcoded string – this must be whatever the password of your admin account is (bold red text above).

Running Sysprep

I then copied the following files to a newly created folder named C:\sysprep, on my newly created vm: the mossconfig.bat, unattend.xml and a batch file containing the command to run sysprep, so you can simple double click. These are in the zip at the end of this article.

Following this, I made a copy of the VM, as I obviously wanted to keep my original master prior to unsealing (renaming accordingly). I loaded this up, and then ran C:\sysprep\runsysprep.bat, which sealed my vm. On next loading my VM, I was then prompted for various settings (e.g. computername, timezone etc). Ideally, when someone logs in for the first time, I wanted mossconfig.bat to run and set up moss. However I ran into an issue, where the search service would not start until i rebooted again (I never had this issue on similar scenarios on Server 2003). I think this was because my computer was part of a workgroup and not a domain. I hence had to run the mossconfig batch file manually after a reboot (see postinstall.bat and mossconfigmanual,bat in the zip file at the end of this article). Note that I have left placeholder batch files in the attached zip, to indicate where the moss configuration code should be called.

Side Note – notes why automated moss install was not successful:

When running  C:\Users\Administrator>stsadm -o osearch -action start -role indexquery -farmcontactemail <email> -farmserviceaccount <domain\username> -farmservicepassword <password> -defaultindexlocation “C:\Program Files\Microsoft Office Servers\12.0\Data\Applications” on first logon from sysprep, I got the error:

‘start’ action failed. Additional information: Cannot start service OSearch on computer ‘.’.

The event log contained two errors:

The Office SharePoint Server Search service depends on the Netlogon service which failed to start because of the following error: The operation completed successfully.

This computer is configured as a member of a workgroup, not as a member of a domain. The Netlogon service does not need to run in this configuration.

I have not yet figured these out, but after I reboot and run exactly the same command, everything runs fine. I will update this article if and when I get this resolved.

Sample files / Notes

  • Note that there is some dialog after sysprep prompts you to change your password (irrelevant of whether the Administrator password was set to never expire). This must match what is used in the answerfile for calling the moss batch file (ideally I would supress this to ensure passwords are consistent, but have not determined how at the time of writing).
  • Once my new VM was created, I installed Virtual PC additions. If you install this before sysprep, it doesn’t seem to persist when unsealing.
  • Also note that you may want to alter the unattend.xml call to mossconfig.bat to use service accounts instead of the administrator account.

If anyone has an ideas on starting osearch from sysprep onfirstlogon, please give me a shout!!!

You May Also Like

About the Author: rnowik

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.