Automated SQL installation for SharePoint server (Using PowerShell or Batch)

As we all know that SharePoint needs SQL server in background one of the important topic is what we need to install it and how. Especially if we have more than one farm intention is to install all SQL with same configuration. Best way to do it by using configuration file.

First we need to copy all installation binaries to location on a local or a network hard drive. Then you need to put configuration file to same location as well. And for a final step you need to run setup.exe with config file parameters.


Here is how to run setup with config file parameters

@Echo on @Echo Installing SQL Server 2012 SP1 Silently # Starting date date/t #Starting time time/t # for run from PowerShell Setup.exe /ConfigurationFile=.\ConfigurationFile.ini # for run from Command Prompt Setup.exe /ConfigurationFile=ConfigurationFile.ini # Ending date date/t # Ending time time/t



And here is configuration file structure

; SQL Server 2012 Configuration File [OPTIONS] ; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter. ACTION="Install" ; Detailed help for command line argument ENU has not been defined yet. ENU="True" ; If Quiet is set to true silent installation is enabled. User will not be able to see any progress. QUIET="True" ; Specifies serial number for product PID="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" ; Setup will display progress only, without any user interaction. QUIETSIMPLE="False" ; Specify whether SQL Server Setup should discover and include product updates. UpdateEnabled="True" ; Accept EULA parameter IACCEPTSQLSERVERLICENSETERMS="TRUE" ; Specifies features to install, uninstall, or upgrade. FEATURES=SQLENGINE,FULLTEXT,IS,SSMS,ADV_SSMS ; Specify the location where SQL Server Setup will obtain product updates.. UpdateSource=".\AllUpdates" ; Displays the command line parameters usage HELP="False" ; Specifies that the detailed Setup log should be piped to the console. INDICATEPROGRESS="False" ; Specifies that Setup should install into WOW64. X86="False" ; Specify the root installation directory for shared components INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server" ; Specify the root installation directory for the WOW64 shared components.

INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server" ; Specify a default or named instance. INSTANCENAME="INSTANCE" ; 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. INSTANCEID="INSTANCE" ; Specify that SQL Server feature usage data can be collected and sent to Microsoft SQMREPORTING="False" ; Specify if errors can be reported to Microsoft to improve future SQL Server releases. ERRORREPORTING="False" ; Specify the installation directory. INSTANCEDIR="D:\Microsoft SQL Server" ; Agent account name AGTSVCACCOUNT="DOMAIN\SVC-ACC-AgentINSTANCE" ; Agent account password AGTSVCPASSWORD="Pa$$w0rd" ; Auto-start service after installation. AGTSVCSTARTUPTYPE="Automatic" ; Startup type for Integration Services. ISSVCSTARTUPTYPE="Automatic" ; Account for Integration Services: Domain\User or system account. ISSVCACCOUNT="DOMAIN\SVC-ACC-FDINSTANCE" ; User Account for Integration Services account ISSVCPASSWORD="Pa$$w0rd" ; CM brick TCP communication port COMMFABRICPORT="0" ; How matrix will use private networks COMMFABRICNETWORKLEVEL="0" ; How inter brick communication will be protected COMMFABRICENCRYPTION="0" ; TCP port used by the CM brick MATRIXCMBRICKCOMMPORT="0" ; Startup type for the SQL Server service. SQLSVCSTARTUPTYPE="Automatic" ; Level to enable FILESTREAM feature at (0, 1, 2 or 3). FILESTREAMLEVEL="0", Po ; Set to "1" to enable RANU for SQL Server Express. ENABLERANU="False" ; Specifies a Windows collation or an SQL collation to use for the Database Engine. SQLCOLLATION="Latin1_General_CI_AS" ; The Database Engine root data directory. INSTALLSQLDATADIR="D:\Microsoft SQL Server" ; Default directory for the Database Engine backup files. SQLBACKUPDIR="G:\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup" ; Default directory for the Database Engine user databases. SQLUSERDBDIR="D:\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" ; Default directory for the Database Engine user database logs. SQLUSERDBLOGDIR="E:\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" ; Directory for Database Engine TempDB files. SQLTEMPDBDIR="F:\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" ; Directory for the Database Engine TempDB log files. SQLTEMPDBLOGDIR="E:\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" ; account for SQL Server service: Domain\User or system account. SQLSVCACCOUNT ="DOMAIN\SVC-ACC-INSTANCE" ; Password for SQL Server service account SQLSVCPASSWORD="Pa$$w0rd" ; account(s) to provision as SQL Server system administrators. SQLSYSADMINACCOUNTS="DOMAIN\SG SQL Admins" ; Provision current user as a Database Engine system administrator for SQL Server 2012. ADDCURRENTUSERASSQLADMIN="False" ; Specify 0 to disable or 1 to enable the TCP/IP protocol. TCPENABLED="0" ; Specify 0 to disable or 1 to enable the Named Pipes protocol. NPENABLED="0" ; Startup type for Browser Service. BROWSERSVCSTARTUPTYPE="Disabled" ; Add description of input argument FTSVCaccount FTSVCACCOUNT ="DOMAIN\SVC-ACC-FDINSTANCE" ; FTSVCACCOUNT Password FTSVCPASSWORD="Pa$$w0rd" ; Test for Browser Service account ; BROWSERSVCACCOUNT ="DOMAIN\SQLBrowser" ; BROVSERSVCPASSWORD="Pa$$w0rd"


NOTE: Similar structure of configuration file is created when you start SQL installation wizard but inside this file some components are missing. This is complete code.

3 thoughts on “Automated SQL installation for SharePoint server (Using PowerShell or Batch)

  1. Here`s how I do it:
    #Loading Variables
    $variables = import-clixml “$env:temp\variables.xml”

    #Configuration Settings
    $domain = $variables.netbiosName
    $svcsql = $domain + “\” + $variables.svcSqlAccount
    $admin = $domain + “\administrator”
    $spadmin = $domain + “\” + $variables.spadminAccount
    $sqlsvcPass = $variables.svcSpAccountsPass
    $sqlExec = “.\setup.exe”

    #Installing SQL
    set-location $variables.sql
    start-process -FilePath $sqlExec -ArgumentList $sqlArgs.ToString()

    This way I am more flexible when providing dynamic parameters with SCVMM. It is also useful when having a single file with all the parameters that you will need. And it is possible to store your passwords encrypted this way 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s