Created
September 2, 2021 03:45
-
-
Save steviecoaster/a1fc1946c1df06a38660e983874124d8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$ErrorActionPreference = 'Stop'; | |
$pp = Get-PackageParameters | |
$packageName= 'sql-server-express' | |
$url = '' | |
$url64 = 'https://download.microsoft.com/download/8/4/c/84c6c430-e0f5-476d-bf43-eaaa222a72e0/SQLEXPR_x64_ENU.exe' | |
$checksum = 'a0086387cd525be62f4d64af4654b2f4778bc98d' | |
if($pp['InstallPath']){ | |
$silentArgs = "/INSTALLPATH=$($pp['InstallPath']) /IACCEPTSQLSERVERLICENSETERMS /Q /ACTION=install /INSTANCEID=SQLEXPRESS /INSTANCENAME=SQLEXPRESS /UPDATEENABLED=FALSE" | |
} | |
else { | |
$silentArgs = "/IACCEPTSQLSERVERLICENSETERMS /Q /ACTION=install /INSTANCEID=SQLEXPRESS /INSTANCENAME=SQLEXPRESS /UPDATEENABLED=FALSE" | |
} | |
$tempDir = Join-Path (Get-Item $env:TEMP).FullName "$packageName" | |
if ($env:packageVersion -ne $null) {$tempDir = Join-Path $tempDir "$env:packageVersion"; } | |
if (![System.IO.Directory]::Exists($tempDir)) { [System.IO.Directory]::CreateDirectory($tempDir) | Out-Null } | |
$fileFullPath = "$tempDir\SQLEXPR.exe" | |
Get-ChocolateyWebFile -PackageName $packageName -FileFullPath $fileFullPath -Url $url -Url64bit $url64 -Checksum $checksum -ChecksumType 'sha1' | |
Write-Host "Extracting..." | |
$extractPath = "$tempDir\SQLEXPR" | |
Start-Process "$fileFullPath" "/Q /x:`"$extractPath`"" -Wait | |
Write-Host "Installing..." | |
$setupPath = "$extractPath\setup.exe" | |
Install-ChocolateyInstallPackage "$packageName" "EXE" "$silentArgs" "$setupPath" -validExitCodes @(0, 3010, 1116) | |
Write-Host "Removing extracted files..." | |
Remove-Item -Recurse "$extractPath" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment