changed installation packages and cleanup

This commit is contained in:
Dariy Nurgaleev
2020-03-24 17:28:01 +07:00
committed by GitHub
parent 66a71260b4
commit d3ab1f0bb0

View File

@@ -7,14 +7,15 @@ Import-Module -Name ImageHelpers -Force;
function Download-FullSQLPackage { function Download-FullSQLPackage {
param( param(
[String]$InstallerPath, [String]$InstallerPath,
[String]$Arguments = ("/MEDIAPATH=${env:Temp}", "/MEDIATYPE=Core","/Action=Download", "/QUIET") [String]$DownloadPath,
[String]$Arguments = ("/MEDIAPATH=$DownloadPath", "/MEDIATYPE=Core","/Action=Download", "/QUIET")
) )
Write-Host "Downloading full package to $InstallerPath..." Write-Host "Downloading full package to $DownloadPath..."
$process = Start-Process -FilePath $InstallerPath -ArgumentList $Arguments -Wait -PassThru $process = Start-Process -FilePath $InstallerPath -ArgumentList $Arguments -Wait -PassThru
$exitCode = $process.ExitCode $exitCode = $process.ExitCode
if ($exitCode -eq 0) if ($exitCode -eq 0)
{ {
Write-Host -Object "Full SQL Express package has been successfully downloaded to $InstallerPath : ExitCode: $exitCode" Write-Host -Object "Full SQL Express package has been successfully downloaded to $DownloadPath : ExitCode: $exitCode"
} }
else else
{ {
@@ -61,12 +62,17 @@ function Start-Installer {
exit $exitCode exit $exitCode
} }
} }
#Main function
$installerUrl = "https://go.microsoft.com/fwlink/?linkid=866658" $installerUrl = "https://go.microsoft.com/fwlink/?linkid=866658"
$downloadPath = "${env:Temp}" $downloadPath = "C:\SQLInstall"
$setupPath = Join-Path $downloadPath "SQLEXPR_x64_ENU" $setupPath = Join-Path $downloadPath "SQLEXPR_x64_ENU"
#Create directory for temporary files
md $downloadPath
Set-Location -Path $downloadPath Set-Location -Path $downloadPath
$installerPath = Start-DownloadWithRetry -Url "https://go.microsoft.com/fwlink/?linkid=866658" -Name "SQL2019-SSEI-Expr.exe" $installerPath = Start-DownloadWithRetry -Url "https://go.microsoft.com/fwlink/?linkid=866658" -DownloadPath $downloadPath -Name "SQL2019-SSEI-Expr.exe"
Download-FullSQLPackage -InstallerPath $installerPath Download-FullSQLPackage -InstallerPath $installerPath -DownloadPath $downloadPath
Unpack-SQLInstaller -InstallPath "$setupPath.exe" Unpack-SQLInstaller -InstallPath "$setupPath.exe"
$resultPath = Join-Path $setupPath "SETUP.exe" $resultPath = Join-Path $setupPath "SETUP.exe"
Start-Installer -InstallerPath $resultPath Start-Installer -InstallerPath $resultPath
#Cleanup folder with installation packages.
Remove-Item $downloadPath -Recurse