Skip to content

Instantly share code, notes, and snippets.

@johnkattenhorn
Last active January 3, 2018 23:13
Show Gist options
  • Save johnkattenhorn/cc77c268a713a029aa15 to your computer and use it in GitHub Desktop.
Save johnkattenhorn/cc77c268a713a029aa15 to your computer and use it in GitHub Desktop.
# Boxstarter options
$Boxstarter.RebootOk=$false # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
# Install SQL Server 2014 Express and Tools (Neither seem to work with Boxstarter Remote)
#cinst -debug mssql2014express-defaultinstance
#cinst -debug MsSqlServerManagementStudio2014Express
# Pre-req for SQL Server 2014
cinst dotnet3.5
try {
if(Test-Path "HKLM:\Software\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion"){
if((Get-ItemProperty -Path HKLM:\Software\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion).CurrentVersion -ge "11.0.3000.0") {
Write-Host "MS SQL already installed"
}
}
else {
$adminsGroupName = (New-Object Security.Principal.SecurityIdentifier 'S-1-5-32-544').Translate([Security.Principal.NTAccount]).Value
$currentUser = Get-CurrentUser
$setupExe = "\\glywlq1\F\Software\SQL2014_ENU_x64\setup.exe"
$setupArgs = "/q /INDICATEPROGRESS /ACTION=Install /ROLE=ALLFeatures_WithDefaults /TCPENABLED=1 /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT=`"NT AUTHORITY\Network Service`" /ASSYSADMINACCOUNTS=`"$($currentUser.Domain)\$($currentUser.Name)`" /SQLSYSADMINACCOUNTS=`"$adminsGroupName`" `"$($currentUser.Domain)\$($currentUser.Name)`" /AGTSVCACCOUNT=`"NT AUTHORITY\Network Service`" /IACCEPTSQLSERVERLICENSETERMS "
Invoke-FromTask "$setupExe $setupArgs" -idletimeout 0
#Install-ChocolateyInstallPackage 'Sql2014' 'exe' "/q /INDICATEPROGRESS /ACTION=Install /ROLE=ALLFeatures_WithDefaults /TCPENABLED=1 /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT=`"NT AUTHORITY\Network Service`" /ASSYSADMINACCOUNTS=`"$($currentUser.Domain)\$($currentUser.Name)`" /SQLSYSADMINACCOUNTS=`"$adminsGroupName`" `"$($currentUser.Domain)\$($currentUser.Name)`" /AGTSVCACCOUNT=`"NT AUTHORITY\Network Service`" /IACCEPTSQLSERVERLICENSETERMS " @(0,3010)
netsh advfirewall firewall add rule name="Allow Access to SQL" Dir=In Action=allow Protocol=tcp LocalPort=1433 Profile=Domain
Write-ChocolateySuccess 'Sql2014'
}
}
catch {
Write-ChocolateyFailure 'Sql2014' $($_.Exception.Message)
throw
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment