Skip to content

Powershell script to install MS SQL Server unattended

License

Notifications You must be signed in to change notification settings

demogorgonz/Install-SqlServer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Install-SqlServer

This script installs MS SQL Server on Windows OS silently from ISO image that can be available locally or downloaded from the Internet. Transcript of entire operation is recorded in the log file.

The script lists parameters provided to the native setup but hides sensitive data. See the provided links for SQL Server silent install details.

The installer is tested with SQL Servers 2016-2019 and PowerShell 3-7.

Prerequisites

  1. Windows OS
  2. MS SQL Server ISO image
  3. Administrative rights

Usage

The fastest way to install core SQL Server is to run in administrative shell without any parameters:

./Install-SqlServer.ps1 

Use ISOPath parameter otherwise.

This assumes number of default parameters and installs by default only SQLEngine feature. Run Get-Help ./Install-SqlServer.ps1 -Full for parameter details.

To test installation, after running this script execute:

Set-Alias sqlcmd "$Env:ProgramFiles\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\SQLCMD.EXE"
"SELECT @@version" | sqlcmd

Notes

  • Behind the proxy use HTTP_PROXY environment variable
  • SQL Server Management Studio isn't distributed along with SQL Server any more. Install via chocolatey: cinst sql-server-management-studio
  • On PowerShell 5 progress bar significantly slows down the download. Use $progressPreference = 'silentlyContinue' to disable it prior to calling this function.

Troubleshooting

Installing on remote machine using PowerShell remote session

The following errors may occur:

There was an error generating the XML document 
    ... Access denied
    ... The computer must be trusted for delegation and the current user account must be configured to allow delegation

The solution: Use WinRM session parameter -Authentication CredSSP.

To be able to use it, the following settings needs to be done on both local and remote machine:

  1. On local machine using gpedit.msc, go to Computer Configuration -> Administrative Templates -> System -> Credentials Delegation.
    Add wsman/*.<domain> (set your own domain) in the following settings
    1. Allow delegating fresh credentials with NTLM-only server authentication
    2. Allow delegating fresh credentials
  2. The remote machine must be set to behave as CredSSP server with Enable-WSManCredSSP -Role server

Links

About

Powershell script to install MS SQL Server unattended

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PowerShell 100.0%