Archives for July 2012

SQL 2012 Unattended Install Scripts

WARNING: This blog post has been superseded by my updated post here. Do not use the article below, as it is outdated.

WARNING: This blog post has been superseded by my updated post here. Do not use the article below, as it is outdated.


Based on my popular article (#1 article of all time) describing how to do a SQL Server 2008 R2 unattended installation, I’ve freshened up the contents for SQL Server 2012. In this case I’m assuming the installation is on Windows Server 2008 R2.

The first step is to create a SQL ini configuration file which contains the configuration settings for the unattended installation. Below I’ve included a sample configuration. Of course you will need to change some paths, such as installation media and program/database/log/tempdb directories. After SQL is installed I configure the service accounts for regular domain users (or managed service accounts in Windows Server 2008 R2, or group service accounts in Windows Server 2012), as I would not recommend leaving SQL to run with “network service” privileges.

Save the contents of the section below into a file called SQL-2012-base.ini.

;SQL Server 2012 Configuration File
; SQL-2012-Base.ini

; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will incorporate the instance ID of the SQL Server instance.


; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter.


; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, MDS, and Tools. The SQL feature will install the Database Engine, Replication, Full-Text, and Data Quality Services (DQS) server. The Tools feature will install Management Tools, Books online components, SQL Server Data Tools, and other shared components.


; Displays the command line parameters usage


; Specifies that the detailed Setup log should be piped to the console.


; Setup will not display any user interface.


; Setup will display progress only without any user interaction.


; Specifies that Setup should install into WOW64. This command line argument is not supported on an IA64 or a 32-bit system.


; Specifies the path to the installation media folder where setup.exe is located.


; Detailed help for command line argument ENU has not been defined yet.


; Parameter that controls the user interface behavior. Valid values are Normal for the full UI,AutoAdvance for a simplied UI, and EnableUIOnServerCore for bypassing Server Core setup GUI block.

; UIMODE=”Normal”

; Specify if errors can be reported to Microsoft to improve future SQL Server releases. Specify 1 or True to enable and 0 or False to disable this feature.


; Specify the root installation directory for shared components.  This directory remains unchanged after shared components are already installed.

INSTALLSHAREDDIR=”D:Program FilesMicrosoft SQL Server”

; Specify the root installation directory for the WOW64 shared components.  This directory remains unchanged after WOW64 shared components are already installed.

INSTALLSHAREDWOWDIR=”D:Program Files (x86)Microsoft SQL Server”

; Specify the installation directory.

INSTANCEDIR=”D:Program FilesMicrosoft SQL Server”

; Specify that SQL Server feature usage data can be collected and sent to Microsoft. Specify 1 or True to enable and 0 or False to disable this feature.


; Specify a default or named instance. MSSQLSERVER is the default instance for non-Express editions and SQLExpress for Express editions. This parameter is required when installing the SQL Server Database Engine (SQL), Analysis Services (AS), or Reporting Services (RS).


; Agent account name


; Auto-start service after installation.


; Startup type for the SQL Server service.


; Level to enable FILESTREAM feature at (0, 1, 2 or 3).


; Set to “1” to enable RANU for SQL Server Express.


; Specifies a Windows collation or an SQL collation to use for the Database Engine.


; Account for SQL Server service: DomainUser or system account.


; Default directory for the Database Engine user databases.


; Default directory for the Database Engine user database logs.


; Directory for Database Engine TempDB files.


; Directory for the Database Engine TempDB log files.


; Provision current user as a Database Engine system administrator for SQL Server 2012 Express.


; Specify 0 to disable or 1 to enable the TCP/IP protocol.


; Specify 0 to disable or 1 to enable the Named Pipes protocol.


; Startup type for Browser Service.


; Accept SQL Server license terms


; Specify whether SQL Server Setup should discover and include product updates. The valid values are True and False or 1 and 0. By default SQL Server Setup will include updates that are found.


; Specify the location where SQL Server Setup will obtain product updates. The valid values are “MU” to search Microsoft Update, a valid folder path, a relative path such as .MyUpdates or a UNC share. By default SQL Server Setup will search Microsoft Update or a Windows Update service through the Window Server Update Services.


; CM brick TCP communication port


; How matrix will use private networks


; How inter brick communication will be protected


; TCP port used by the CM brick


At this point I wrote a little batch file to call the SQL installer, pass along the group I wanted to be designated as the SQL administrator, and also configure Windows Server 2008 R2 auditing so SQL security events could get logged in the main Windows security event log. This also assumes the installation media is mounted to the Z: drive, so modify to suit your needs. I put the text below into a file called SQL-2012-base.cmd.

:: SQL 2012 Installation Script
:: SQL-2012-Base.cmd

@echo off
IF “%1″==”” GOTO Error

:: Install base SQL Server 2012 Enterprise

title SQL Server 2012 Base Installation
echo Installing base SQL Server 2012…


auditpol /set /subcategory:”application generated” /success:enable /failure:enable
exit /B

Echo Script requires DBAdmin argument in the form domainGroup

To perform the unattended installation of SQL Server 2012 on Windows Server 2008 R2, do the following:
1. Open an elevated powershell prompt and install .NetFramework 3.5
import-module servermanager
add-windowsfeature as-net-framework
2.  Mount the SQL Server 2012 ISO to the Z drive (or whatever you chose and modified the scripts to use)
3. Copy the two files you just created (the .ini and .cmd) to the root of the D: drive
4. Open an elevated command prompt and CD to the Z drive.
5. Type: D:SQL-2012-base.cmd contosoSQL-DBAdmin (replace with the domain and group or user that will be SQL administrator)
6. Wait 10+ minutes for the installation to complete, and you should get a return code of 0.
Viola…very similar to SQL Server 2008 R2.


Slipstream SQL Server 2008 R2 Service Pack 2

One of the new features added to Microsoft SQL Server 2008 and R2 is the ability to slipstream a service pack into the installation. This streamlines the installation, and reduces human error. Now that SQL Server 2008 R2 SP2 is officially out, here’s how to slipstream SQL Server 2008 R2 Service Pack 2. I’ve updated the instructions from the MSDN SQL 2008 R2 SP1 blog article to reflect SP2 filenames.

1. Download SQL Server 2008 R2 SP2 here. Note that you need to download all three architectures (IA64, x64, x86) even if you never plan on using them.

  • SQLServer2008R2SP2-KB2630458-IA64-ENU.exe
  • SQLServer2008R2SP2-KB2630458-x64-ENU.exe
  • SQLServer2008R2SP2-KB2630458-x86-ENU.exe

2. Copy your original SQL Server 2008 R2 media to a folder (e.g. SQL2008R2_SP2), I used the E drive so my path was E:SQL2008R2_SP2.

3. You now need to extract the packages, using the path to where you copied the original source media.

SQLServer2008R2SP2-KB2630458-IA64-ENU.exe /x:e:\SQL2008R2_SP2SP
SQLServer2008R2SP2-KB2630458-x64-ENU.exe /x:e:\SQL2008R2_SP2SP
SQLServer2008R2SP2-KB2630458-x86-ENU.exe /x:e:\SQL2008R2_SP2SP

4. Replace the original setup.exe with the SP2 version:

robocopy E:\SQL2008R2_SP2SP E:\SQL2008R2_SP2 Setup.exe

5. Copy all of the files, excluding folders and the Microsoft.SQL.Chainer.PackageData.dll file to overwrite the non-SP2 files.

robocopy E:\SQL2008R2_SP2\SP\x86 E:\SQL2008R2_SP2\x86 /XF Microsoft.SQL.Chainer.PackageData.dll
robocopy E:\SQL2008R2_SP2\SP\x64 E:\SQL2008R2_SP2\x64 /XF Microsoft.SQL.Chainer.PackageData.dll 
robocopy E:\SQL2008R2_SP2\SP\ia64 E:\SQL2008R2_SP2\ia64 /XF Microsoft.SQL.Chainer.PackageData.dll

6. To tell the SQL server installer where to find the service pack files you need to update all three DefaultSetup.ini files. They are located under E:\SQL2008R2_SP2x86, x64 and ia64. Add the following line to the end of each file:


7. Your SP2 slipstream media is now complete. Run Setup.exe like you normally would and enjoy an integrated installation of SQL Server 2008 R2 with SP2.

Update: You may get an installation error if installing on a 64-bit server. You may need to rename the sqlncli.msi file in SP1033_ENU_LPx64setupx64 to sqlncli_amd64.msi.

Windows Server 2012 Unattended Installation

One of the common tasks that you may do on a regular basis is installing Windows Server 2012 and you want to automate it as much as possible. Using similar tools to those used with Windows Server 2008 R2, you can create an autounattend.xml file that you inject into the Windows Server 2012 installation ISO for a hands-free install.

The same set of instructions would also work for Windows 8 as well, but you will need to use the Windows 8 install.wim image, and also pay attention to whether you want to automate a 32-bit or 64-bit installation. The autounattend.xml can contain configuration data for both, so only one xml file is needed. If you want to download a pre-configured autounattend.xml file, you can find it here on my Skydrive folder.

1. Download the Windows ADK (Assessment and Deployment Kit) from this link. Never mind that it says Windows 8, as it will work with Windows Server 2012 since they are the same code base.

2. Start the installation process and after a long download select the two options below (Deployment Tools and Windows Preinstallation Environment (Windows PE)). WinPE is technically optional, but in case you need it in the future, I’d install it anyway.

3. After the installation completes go to the Start Menu and select Windows Kits > Windows ADK > Windows System Image Manager.

4. Mount the ISO image of Windows Server 2012, go to the sources directory and copy install.wim to a local drive, such as D.

5. From the File menu click on Select Windows Image, find the install.wim you copied, then select the edition that you want to build an answer file for. I selected SERVERSTANDARD.

6. Next it will complain that a catalog cannot be found, so it will build one for you, taking a few minutes. After the catalog is built, from the file menu select New Answer File.

7. Scroll through the Components pane and select amd64_Microsoft-Windows-International-Core-WinPE-_6.2.9200.0_neutral, as shown below, right click, and add to Pass 1.

8. In the Answer File pane click on the component, and fill in the language settings as appropriate. In this case it is configured for US English. You can find a list of the codes here. You also need to configure the SetupUILanguage too.
9. Configuring the disk partitions is tedious, but required. To do that, find amd64_Microsoft-Windows-Setup_6.2.9200.0_neutral and add it to Pass 1 as well.
10. In the Answer File pane right click DiskConfiguration and select Insert New Disk. Right click on CreatePartitions and select Insert New CreatePartition. Configure the partition as shown below. This will create a 100MB primary boot partition. Note: The default in 2008 R2 was 100MB, but in 2012 this is now 350MB. I would suggest using 350MB instead of the 100MB in the screenshot.
 11. Create a second partition, but this time set Extend to true, and don’t configure a size. This will use the remainder of the disk size.
12. In the Answer File pane click on Disk and change the ID to 0 and WillWipeDisk to true.
13. Right click on ModifyPartition and select Insert New ModifyPartition. Configure the partition as shown below.
14. Add a second ModifyPartitions and configure as shown below:
15. Drill down to the OSImage option and configure as shown below:
16. Right click InstallFrom and select Insert New Metadata. Configure the metadata as shown below. To determine the proper label just think back to when you opened the Windows image (step 5) and enter the image name exactly as it is listed.
17. Configure the InstallTo and use DiskID 0 and PartitionID 2.
18. Configure the UserData options as shown below.
19. Configure the UserDataProductKey option. The key you use will vary depending on how you are going to activate it (KMS or MAK). You should use the GVLK (generic volume license key) that Microsoft publishes here if you use a KMS server, or your MAK key.
20. Add the amd64_Microsoft-Windows-Shell-Setup_6.2.9200.0_neutral component to Pass 4 specialize.

21. In the Answer File pane click on amd64_Microsoft-Windows-Shell-Setup_6.2.9200.0_neutral  and configure the highlighted items below (use the same key as before). You can change the computer name, or leave it blank and it will create a random name upon installation. For a list of timezone values, click here.
22. Add the amd64_Microsoft-Windows-Shell-Setup_6.2.9200.0_neutral component to Pass 7 oobesystem. In the Answer File pane click on amd64_Microsoft-Windows-Shell-Setup_6.2.9200.0_neutral and configure the highlighted items below.
23. Normally I configure autologon for a count of 2, so my image build process goes quicker and in case I forget the administrator password I configured in the answer file I can reset it during the first two reboots. You will also need to configure the password. Enter a password, and when the answer file is written it will be encrypted.
24. Under UserAccounts, configure the AdministratorPassword with the same password you entered for the AutoLogon information.
25. Save the file as autounattend.xml and verify that no errors are shown in the validation pane. You will see a lot of warnings, but that is normal.
26. Open the Windows Server 2012 ISO image in an ISO editor, like UltraISO. Add the autounattend.xml file to the ROOT of the ISO image. Save the ISO, and then configure a VM or physical server to boot from it and verify that there are no prompts or errors during the installation process. Note that the disk configuration and data will be wiped during the installation process.