Created
November 15, 2016 08:40
-
-
Save LeeCampbell/607bb1c7a6e8900aa1a882dc5f526154 to your computer and use it in GitHub Desktop.
Install SQL 2016 Dev command line (Powershell)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Installs SQL Server locally with standard settings for Developers/Testers. | |
# Install SQL from command line help - https://msdn.microsoft.com/en-us/library/ms144259.aspx | |
$sw = [Diagnostics.Stopwatch]::StartNew() | |
$currentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name; | |
$SqlServerIsoImagePath = "???\Downloads\Microsoft\SQL Server 2016 Developer Edition\en_sql_server_2016_developer_x64_dvd_8777069.iso" | |
#Mount the installation media, and change to the mounted Drive. | |
$mountVolume = Mount-DiskImage -ImagePath $SqlServerIsoImagePath -PassThru | |
$driveLetter = ($mountVolume | Get-Volume).DriveLetter | |
$drivePath = $driveLetter + ":" | |
push-location -path "$drivePath" | |
#Install SQL Server locally with our default settings. | |
# Only the Sql Engine and LocalDB | |
# i.e. no Replication, FullText, Data Quality, PolyBase, R, AnalysisServices, Reporting Services, Integration service, Master Data Services, Books Online(BOL) or SDK are installed. | |
.\Setup.exe /q /ACTION=Install /FEATURES=SQLEngine, LocalDB /UpdateEnabled /UpdateSource=MU /X86=false /INSTANCENAME=MSSQLSERVER /INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server" /INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server" /SQLSVCINSTANTFILEINIT="True" /INSTANCEDIR="C:\Program Files\Microsoft SQL Server" /AGTSVCACCOUNT="NT Service\SQLSERVERAGENT" /AGTSVCSTARTUPTYPE="Manual" /SQLSVCSTARTUPTYPE="Automatic" /SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS" /SQLSVCACCOUNT="NT Service\MSSQLSERVER" /SECURITYMODE="SQL" /SAPWD="Passw0rd" /SQLSYSADMINACCOUNTS="$currentUserName" /IACCEPTSQLSERVERLICENSETERMS | |
#Dismount the installation media. | |
pop-location | |
Dismount-DiskImage -ImagePath $SqlServerIsoImagePath | |
#print Time taken to execute | |
$sw.Stop() | |
"Sql install script completed in {0:c}" -f $sw.Elapsed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Uninstalls a standard CashConverter SQL Server local installation. | |
# Also removes all database files. i.e. should be a clean uninstall | |
# Install SQL from command line help - https://msdn.microsoft.com/en-us/library/ms144259.aspx | |
$sw = [Diagnostics.Stopwatch]::StartNew() | |
$currentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name; | |
$SqlServerIsoImagePath = "???\Downloads\Microsoft\SQL Server 2016 Developer Edition\en_sql_server_2016_developer_x64_dvd_8777069.iso" | |
#Mount the installation media, and change to the mounted Drive. | |
$mountVolume = Mount-DiskImage -ImagePath $SqlServerIsoImagePath -PassThru | |
$driveLetter = ($mountVolume | Get-Volume).DriveLetter | |
$drivePath = $driveLetter + ":" | |
push-location -path "$drivePath" | |
#Install SQL Server locally with our default settings. | |
# Assumes only the Sql Engine and LocalDB were installed | |
.\Setup.exe /q /ACTION=UNINSTALL /FEATURES=SQLEngine, LocalDB /INSTANCENAME=MSSQLSERVER | |
#Dismount the installation media. | |
pop-location | |
Dismount-DiskImage -ImagePath $SqlServerIsoImagePath | |
#Clear out the orphaned database files | |
# As per the install script INSTANCENAME=MSSQLSERVER & INSTANCEDIR="C:\Program Files\Microsoft SQL Server" | |
Remove-Item -Recurse -Force "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\" | |
#print Time taken to execute | |
$sw.Stop() | |
"Sql install script completed in {0:c}" -f $sw.Elapsed; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment