Welcome to ciysys blog

Installing MSSQL server with Powershell

Published on: 11th Nov 2019

Updated on: 16th Jan 2022


When you are installing the MSSQL Express, you might find out that you missed out changing the collation, change the instance name and other standard settings while installing them.

To avoid patching the SQL server settings, it's better to use a script and all team members to follow. Here is the script that I have come up with to install the MSSQL.

$sql_setup_file = "F:\my-setupFiles\sql2012 express\SQLEXPRWT_x64_ENU.exe "
$db_dir = "F:\my_database"
$bak_dir = "F:\my_database_backup"
$sa_pwd = "1234567890"


Write-Host "Installing SQL server... please wait.."

#start the installation.           
Start-Process -FilePath $sql_setup_file -ArgumentList $param -Wait

Write-Host "SQL installation completed"

Notes: please change the $sa_pwd before running the script.

Jump to #POWERSHELL blog


Lau Hon Wan, software developer.