setup-sqlserver.ps1 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # This script downloads and installs SQL Server and opens it on port 1433.
  2. #
  3. # To run this script, run an elevated Command Prompt and enter:
  4. #
  5. # powershell -ExecutionPolicy Bypass -File <this script's filename>
  6. $basedir = "C:\FrameworkBenchmarks"
  7. $workdir = "$basedir\installs"
  8. New-Item -Path $workdir -Type directory -Force | Out-Null
  9. Write-Host "Downloading SQL Server (several GBs)...`n"
  10. # URLs from http://www.microsoft.com/en-us/download/details.aspx?id=35575
  11. $sqlserver_exe_url = "http://download.microsoft.com/download/3/B/D/3BD9DD65-D3E3-43C3-BB50-0ED850A82AD5/SQLServer2012SP1-FullSlipstream-x64-ENU.exe"
  12. $sqlserver_exe_local = "$workdir\SQLServer2012SP1-FullSlipstream-x64-ENU.exe"
  13. (New-Object System.Net.WebClient).DownloadFile($sqlserver_exe_url, $sqlserver_exe_local)
  14. $sqlserver_box_url = "http://download.microsoft.com/download/3/B/D/3BD9DD65-D3E3-43C3-BB50-0ED850A82AD5/SQLServer2012SP1-FullSlipstream-x64-ENU.box"
  15. $sqlserver_box_local = "$workdir\SQLServer2012SP1-FullSlipstream-x64-ENU.box"
  16. (New-Object System.Net.WebClient).DownloadFile($sqlserver_box_url, $sqlserver_box_local)
  17. Write-Host "Installing SQL Server...`n"
  18. # Install only the SQL Server database engine.
  19. # Use a default instance name.
  20. # Make %COMPUTERNAME%\Administrators have administrative rights.
  21. # Allow Windows Authentication or old-style SQL authentication.
  22. # The password of the sa account is specified.
  23. # SQL Server will be listening on TCP port 1433.
  24. #
  25. Start-Process "$sqlserver_exe_local" "/q /action=install /features=SQLEngine /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS=Administrators /securitymode=SQL /sapwd=S3cr3tS3cr3t /TCPENABLED=1 /IACCEPTSQLSERVERLICENSETERMS" -Wait
  26. Write-Host "Configuring firewall...`n"
  27. New-NetFirewallRule -DisplayName "SQL 1433" -Action Allow -Direction Inbound -LocalPort 1433 -Protocol TCP | Out-Null
  28. # TODO: Run T-SQL files to create database and tables? To do that, we'd need to have the files config\create-sqlserver*.sql locally