Last active
November 29, 2016 09:54
-
-
Save JonCubed/c8799092fae3d2862545c0b9c86e2da3 to your computer and use it in GitHub Desktop.
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
<# | |
#OPTIONAL | |
** Windows 7 ** | |
Should upgrade to WMF 5 first for reduced errors | |
https://www.microsoft.com/en-us/download/details.aspx?id=50395 | |
# If Dev Machine | |
[Environment]::SetEnvironmentVariable("BoxStarter:DataDrive", "D", "Machine") # for reboots | |
[Environment]::SetEnvironmentVariable("BoxStarter:DataDrive", "D", "Process") # for right now | |
[Environment]::SetEnvironmentVariable("choco:sqlserver2014:isoImage", "D:\Downloads\en_sql_server_2014_rc_2_x64_dvd_8509698.iso", "Machine") # for reboots | |
[Environment]::SetEnvironmentVariable("choco:sqlserver2014:isoImage", "D:\Downloads\en_sql_server_2014_rc_2_x64_dvd_8509698.iso", "Process") # for right now | |
[Environment]::SetEnvironmentVariable("choco:sqlserver2016:isoImage", "D:\Downloads\en_sql_server_2016_rc_2_x64_dvd_8509698.iso", "Machine") # for reboots | |
[Environment]::SetEnvironmentVariable("choco:sqlserver2016:isoImage", "D:\Downloads\en_sql_server_2016_rc_2_x64_dvd_8509698.iso", "Process") # for right now | |
# If Home Machine | |
[Environment]::SetEnvironmentVariable("BoxStarter:InstallHome", "1", "Machine") # for reboots | |
[Environment]::SetEnvironmentVariable("BoxStarter:InstallHome", "1", "Process") # for right now | |
#START | |
START http://boxstarter.org/package/nr/url?http://boxstarter.org/package/nr/url?https://raw.githubusercontent.com/JonCubed/boxstarter/master/box.ps1 | |
wget -Uri 'https://gist.githubusercontent.com/JonCubed/24eb6f1f6a831c6d2b3786e20dfe62d0/raw/acb5e52acfd2b9780dda5324222b60740faef37c/bootstrap-sqlserver.ps1' -OutFile "$($env:temp)\bootstrap.ps1";&Invoke-Command -ScriptBlock { &"$($env:temp)\bootstrap.ps1" -SqlServer2014IsoImage 'c:\sql2014\en_sql_server_2014_standard_edition_x64_dvd_3932034.iso' } | |
#> | |
$Boxstarter.RebootOk=$true | |
$Boxstarter.NoPassword=$false | |
$Boxstarter.AutoLogin=$true | |
$checkpointPrefix = 'BoxStarter:Checkpoint:' | |
function Get-CheckpointName | |
{ | |
param | |
( | |
[Parameter(Mandatory=$true)] | |
[string] | |
$CheckpointName | |
) | |
return "$checkpointPrefix$CheckpointName" | |
} | |
function Set-Checkpoint | |
{ | |
param | |
( | |
[Parameter(Mandatory=$true)] | |
[string] | |
$CheckpointName, | |
[Parameter(Mandatory=$true)] | |
[string] | |
$CheckpointValue | |
) | |
$key = Get-CheckpointName $CheckpointName | |
[Environment]::SetEnvironmentVariable($key, $CheckpointValue, "Machine") # for reboots | |
[Environment]::SetEnvironmentVariable($key, $CheckpointValue, "Process") # for right now | |
} | |
function Get-Checkpoint | |
{ | |
param | |
( | |
[Parameter(Mandatory=$true)] | |
[string] | |
$CheckpointName | |
) | |
$key = Get-CheckpointName $CheckpointName | |
[Environment]::GetEnvironmentVariable($key, "Process") | |
} | |
function Clear-Checkpoints | |
{ | |
$checkpointMarkers = Get-ChildItem Env: | where { $_.name -like "$checkpointPrefix*" } | Select -ExpandProperty name | |
foreach ($checkpointMarker in $checkpointMarkers) { | |
[Environment]::SetEnvironmentVariable($checkpointMarker, '', "Machine") | |
[Environment]::SetEnvironmentVariable($checkpointMarker, '', "Process") | |
} | |
} | |
function Get-SystemDrive | |
{ | |
return $env:SystemDrive[0] | |
} | |
function Get-DataDrive | |
{ | |
$driveLetter = Get-SystemDrive | |
if((Test-Path env:\BoxStarter:DataDrive) -and (Test-Path $env:BoxStarter:DataDrive)) | |
{ | |
$driveLetter = $env:BoxStarter:DataDrive | |
} | |
return $driveLetter | |
} | |
function Install-SqlServer | |
{ | |
param ( | |
$InstallDrive | |
) | |
$dataPath = Join-Path $InstallDrive "Data\Sql" | |
#rejected by chocolatey.org since iso image is required :| | |
$sqlPackageSource = "https://www.myget.org/F/nm-chocolatey-packs/api/v2" | |
choco install sqlstudio --limitoutput | |
if ((Test-Path env:\choco:sqlserver2014:isoImage) -or (Test-Path env:\choco:sqlserver2014:setupFolder)) | |
{ | |
# SQL2014 has dependency on .net 3.5 | |
choco install NetFx3 --source windowsfeatures --limitoutput | |
# Note: No support for Windows 7 https://msdn.microsoft.com/en-us/library/ms143506.aspx | |
if (Test-PendingReboot) { Invoke-Reboot } | |
$env:choco:sqlserver2014:INSTALLSQLDATADIR=$dataPath | |
$env:choco:sqlserver2014:INSTANCEID="sql2014" | |
$env:choco:sqlserver2014:INSTANCENAME="sql2014" | |
$env:choco:sqlserver2014:FEATURES="SQLENGINE,ADV_SSMS" | |
$env:choco:sqlserver2014:AGTSVCACCOUNT="NT Service\SQLAgent`$SQL2014" | |
$env:choco:sqlserver2014:SQLSVCACCOUNT="NT Service\MSSQL`$SQL2014" | |
$env:choco:sqlserver2014:SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS" | |
choco install sqlserver2014 --source=c:\packages | |
} | |
if ((Test-Path env:\choco:sqlserver2016:isoImage) -or (Test-Path env:\choco:sqlserver2016:setupFolder)) | |
{ | |
# Note: No support for Windows 7 https://msdn.microsoft.com/en-us/library/ms143506.aspx | |
if (Test-PendingReboot) { Invoke-Reboot } | |
$env:choco:sqlserver2016:INSTALLSQLDATADIR=$dataPath | |
$env:choco:sqlserver2016:INSTANCEID="sql2016" | |
$env:choco:sqlserver2016:INSTANCENAME="sql2016" | |
$env:choco:sqlserver2016:AGTSVCACCOUNT="NT Service\SQLAgent`$SQL2016" | |
$env:choco:sqlserver2016:SQLSVCACCOUNT="NT Service\MSSQL`$SQL2016" | |
$env:choco:sqlserver2016:SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS" | |
choco install sqlserver2016 --source=$sqlPackageSource | |
} | |
} | |
$dataDriveLetter = Get-DataDrive | |
$dataDrive = "$dataDriveLetter`:" | |
# disable chocolatey default confirmation behaviour (no need for --yes) | |
choco feature enable --name=allowGlobalConfirmation | |
Install-SqlServer -InstallDrive $dataDrive | |
# re-enable chocolatey default confirmation behaviour | |
choco feature disable --name=allowGlobalConfirmation | |
if (Test-PendingReboot) { Invoke-Reboot } | |
Clear-Checkpoints |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment