Microsoft® SQL Server® 2012 Bible

(Ben Green) #1

63


Chapter 3: Installing SQL Server


3



  1. Verify that you can run and load unsigned PowerShell scripts and fi les. In the
    PowerShell command line, type get-executionpolicy to verify the current execu-
    tion policy. If it is not set to RemoteSigned, you need to change it to this value
    by executing the following command:
    Set-ExecutionPolicy RemoteSigned

  2. Next, load the PowerShell function in the script fi le by executing the following
    command:
    c:\scripts\Install-Sql2012.ps1


Notice the. and blank space before the script fi le path. The. and blank space is a
required character to dot-source the script fi le.


  1. Verify that the function has been loaded by issuing the following command:
    get-command Install-Sql2012


A single row is returned showing CommandType Function and Name Install-Sql2012.


  1. At this point you are ready to invoke the PowerShell function you just loaded.
    Invoke the Install-Sql2012 as follows:
    Install-Sql2012 -Param1 Param1Value -Param2 Param2Value


For example, the following command invokes the Install-Sql2012 function and sets the
SQL Server service account and password along with the Instance Name and initiates a SQL
Server 2012 installation.

Install-Sql2012 -Path d:\ -ServiceAccount "winserver\Administrator"
-ServicePassword "P@ssword"
-SaPassword "P@ssword"
-InstanceName "MyInstanceName"

The SQL Server 2012 installation path may differ depending on your installation media.

Figure 3-15 shows the PowerShell command-line window with the steps necessary to invoke
the Install-Sql2012 function.

A community-based project called SPADE that automates SQL Server installations using PowerShell is available for down-
load at Codeplex.com. For more information about this project visit http://sqlspade.codeplex.com/.

c03.indd 63c03.indd 63 7/30/2012 4:10:08 PM7/30/2012 4:10:08 PM


http://www.it-ebooks.info
Free download pdf