< Back

Install-DbaInstance

Mon Jan 13, 2020 12:05 pm

NAME Install-DbaInstance



SYNOPSIS

This function will help you to quickly install a SQL Server instance.





SYNTAX

Install-DbaInstance [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [-Version]

<String> [[-InstanceName] <String>] [[-SaCredential] <Pscredential>] [[-Credential] <Pscredential>]

[[-Authentication] <String>] [[-ConfigurationFile] <System.Object>] [[-Configuration] <Hashtable>] [[-Path]

<System.String[]>] [[-Feature] <System.String[]>] [[-AuthenticationMode] <String>] [[-InstancePath] <String>]

[[-DataPath] <String>] [[-LogPath] <String>] [[-TempPath] <String>] [[-BackupPath] <String>] [[-UpdateSourcePath]

<String>] [[-AdminAccount] <System.String[]>] [[-Port] <Int>] [[-Throttle] <Int>] [[-ProductID] <String>]

[[-EngineCredential] <Pscredential>] [[-AgentCredential] <Pscredential>] [[-ASCredential] <Pscredential>]

[[-ISCredential] <Pscredential>] [[-RSCredential] <Pscredential>] [[-FTCredential] <Pscredential>]

[[-PBEngineCredential] <Pscredential>] [[-SaveConfiguration] <String>] [-PerformVolumeMaintenanceTasks <Switch>]

[-Restart <Switch>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

This function will help you to quickly install a SQL Server instance on one or many computers.



Some of the things this function will do for you:



* Add your login as an admin to the new instance



* Search for SQL Server installations in the specified file repository



* Generate SA password if needed



* Install specific features using 'Default' and 'All' templates or cherry-pick the ones you need



* Set number of tempdb files based on number of cores (SQL2016+)



* Activate .Net 3.5 feature for SQL2012/2014



* Restart the machine if needed after the installation is done



Fully customizable installation parameters allow you to:



* Use existing Configuration.ini files for the installation



* Define service account credentials using native Powershell syntax



* Override any configurations by using -Configuration switch



* Change the TCP port after the installation is done



* Enable 'Perform volume maintenance tasks' for the SQL Server account



Note that the dowloaded installation media must be extracted and available to the server where the installation

runs.



NOTE: If no ProductID (PID) is found in the configuration files/parameters, Evaluation version is going to be

installed.





PARAMETERS

-AdminAccount [<System.String[]>]

One or more members of the sysadmin group. Uses UserName from the -Credential parameter if specified, or

current Windows user by default.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-AgentCredential [<Pscredential>]

Service account of the SQL Server Agent



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ASCredential [<Pscredential>]

Service account of the Analysis Services



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Authentication [<String>]

Chooses an authentication protocol for remote connections.

If the protocol fails to establish a connection



Defaults:

* CredSSP when -Credential is specified - due to the fact that repository Path is usually a network share and

credentials need to be passed to the remote host

to avoid the double-hop issue.

* Default when -Credential is not specified. Will likely fail if a network path is specified.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-AuthenticationMode [<String>]

Chooses between Mixed and Windows authentication.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupPath [<String>]

Path to the Backup folder.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Configuration [<Hashtable>]

A hashtable with custom configuration items that you want to use during the installation.

Overrides all other parameters.

For example, to define a custom server collation you can use the following parameter:

PS> Install-DbaInstance -Version 2017 -Configuration @{ SQLCOLLATION = 'Latin1_General_BIN' }



Full list of parameters can be found here: https://docs.microsoft.com/en-us/sql/da ... ll-windows

/install-sql-server-from-the-command-prompt#Install



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ConfigurationFile [<System.Object>]

The path to the custom Configuration.ini file.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Credential [<Pscredential>]

Used when executing installs against remote servers



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DataPath [<String>]

Path to the Data folder.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.

This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables

advanced scripting.

Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own

try/catch.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EngineCredential [<Pscredential>]

Service account of the SQL Server Database Engine



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Feature [<System.String[]>]

Features to install. Templates like "Default" and "All" can be used to setup a predefined set of components.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-FTCredential [<Pscredential>]

Service account of the Full-Text catalog service



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InstanceName [<String>]

Name of the SQL Server instance to install. Overrides the instance name specified in -SqlInstance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InstancePath [<String>]

Root folder for instance components. Includes SQL Server logs, system databases, etc.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ISCredential [<Pscredential>]

Service account of the Integration Services



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-LogPath [<String>]

Path to the Log folder.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Path [<System.String[]>]

Path to the folder(s) with SQL Server installation media downloaded. It will be scanned recursively for a

corresponding setup.exe.

Path should be available from the remote server.

If a setup.exe file is missing in the repository, the installation will fail.

Consider setting the following configuration if you want to omit this parameter: `Set-DbatoolsConfig -Name

Path.SQLServerSetup -Value '\\\\path\\to\\installations'`



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-PBEngineCredential [<Pscredential>]

Service account of the PolyBase service



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-PerformVolumeMaintenanceTasks [<Switch>]

Allow SQL Server service account to perform Volume Maintenance tasks.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Port [<Int>]

After successful installation, changes SQL Server TCP port to this value. Overrides the port specified in

-SqlInstance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ProductID [<String>]

Product ID, or simply, serial number of your SQL Server installation, which will determine which version to

install.

If the PID is already built into the installation media, can be ignored.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Restart [<Switch>]

Restart computer automatically if a restart is required before or after the installation.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-RSCredential [<Pscredential>]

Service account of the Reporting Services



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SaCredential [<Pscredential>]

Securely provide the password for the sa account when using mixed mode authentication.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SaveConfiguration [<String>]

Save installation configuration file in a custom location. Will not be preserved otherwise.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target computer and, optionally, a new instance name and a port number.

Use one of the following generic formats:

Server1

Server2\\Instance1

Server1\\Alpha:1533, Server2\\Omega:1566

"ServerName\\NewInstanceName,1534"



You can also define instance name and port using -InstanceName and -Port parameters.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-TempPath [<String>]

Path to the TempDB folder.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Throttle [<Int>]

Maximum number of computers updated in parallel. Once reached, the update operations will queue up.

Default: 50



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-UpdateSourcePath [<String>]

Path to the updates that you want to slipstream into the installation.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Version [<String>]

SQL Server version you wish to install.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Install

Author: Reitse Eskens (@2meterDBA), Kirill Kravtsov (@nvarscar)

Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



C:\\PS>Install-DbaInstance -Version 2017 -Feature All



Install a default SQL Server instance and run the installation enabling all features with default settings.

Automatically generates configuration.ini

-------------------------- EXAMPLE 2 --------------------------



C:\\PS>Install-DbaInstance -SqlInstance sql2017\\sqlexpress, server01 -Version 2017 -Feature Default



Install a named SQL Server instance named sqlexpress on sql2017, and a default instance on server01. Automatically

generates configuration.ini.

Default features will be installed.

-------------------------- EXAMPLE 3 --------------------------



C:\\PS>Install-DbaInstance -Version 2008R2 -SqlInstance sql2017 -ConfigurationFile C:\\temp\\configuration.ini



Install a default named SQL Server instance on the remote machine, sql2017 and use the local configuration.ini

-------------------------- EXAMPLE 4 --------------------------



C:\\PS>Install-DbaInstance -Version 2017 -InstancePath G:\\SQLServer -UpdateSourcePath \\\\my\\updates



Run the installation locally with default settings apart from the application volume, this will be redirected to

G:\\SQLServer.

The installation procedure would search for SQL Server updates in \\\\my\\updates and slipstream them into the

installation.

-------------------------- EXAMPLE 5 --------------------------



C:\\PS>$svcAcc = Get-Credential MyDomain\\SvcSqlServer



C:\\PS> Install-DbaInstance -Version 2016 -InstancePath D:\\Root -DataPath E: -LogPath L:

-PerformVolumeMaintenanceTasks -EngineCredential $svcAcc



Install SQL Server 2016 instance into D:\\Root drive, set default data folder as E: and default logs folder as L:.

Perform volume maintenance tasks permission is granted. MyDomain\\SvcSqlServer is used as a service account for

SqlServer.

-------------------------- EXAMPLE 6 --------------------------



C:\\PS>$config = @{



AGTSVCSTARTUPTYPE = "Manual"

SQLCOLLATION = "Latin1_General_CI_AS"

BROWSERSVCSTARTUPTYPE = "Manual"

FILESTREAMLEVEL = 1

}

C:\\PS> Install-DbaInstance -SqlInstance localhost\\v2017:1337 -Version 2017 -Configuration $config



Run the installation locally with default settings overriding the value of specific configuration items.

Instance name will be defined as 'v2017'; TCP port will be changed to 1337 after installation.



RELATED LINKS