From d3ab1f0bb0afb5ffcc95692fab9387de4b0c7566 Mon Sep 17 00:00:00 2001 From: Dariy Nurgaleev <50947177+Darleev@users.noreply.github.com> Date: Tue, 24 Mar 2020 17:28:01 +0700 Subject: [PATCH] changed installation packages and cleanup --- .../scripts/Installers/Install-SQLExpress.ps1 | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/images/win/scripts/Installers/Install-SQLExpress.ps1 b/images/win/scripts/Installers/Install-SQLExpress.ps1 index 419e410d..99da3ccd 100644 --- a/images/win/scripts/Installers/Install-SQLExpress.ps1 +++ b/images/win/scripts/Installers/Install-SQLExpress.ps1 @@ -7,14 +7,15 @@ Import-Module -Name ImageHelpers -Force; function Download-FullSQLPackage { param( [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 $exitCode = $process.ExitCode 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 { @@ -61,12 +62,17 @@ function Start-Installer { exit $exitCode } } +#Main function $installerUrl = "https://go.microsoft.com/fwlink/?linkid=866658" -$downloadPath = "${env:Temp}" +$downloadPath = "C:\SQLInstall" $setupPath = Join-Path $downloadPath "SQLEXPR_x64_ENU" +#Create directory for temporary files +md $downloadPath Set-Location -Path $downloadPath -$installerPath = Start-DownloadWithRetry -Url "https://go.microsoft.com/fwlink/?linkid=866658" -Name "SQL2019-SSEI-Expr.exe" -Download-FullSQLPackage -InstallerPath $installerPath +$installerPath = Start-DownloadWithRetry -Url "https://go.microsoft.com/fwlink/?linkid=866658" -DownloadPath $downloadPath -Name "SQL2019-SSEI-Expr.exe" +Download-FullSQLPackage -InstallerPath $installerPath -DownloadPath $downloadPath Unpack-SQLInstaller -InstallPath "$setupPath.exe" $resultPath = Join-Path $setupPath "SETUP.exe" -Start-Installer -InstallerPath $resultPath \ No newline at end of file +Start-Installer -InstallerPath $resultPath +#Cleanup folder with installation packages. +Remove-Item $downloadPath -Recurse