2023-07-15 10:18:13 +00:00
|
|
|
. "$PSScriptRoot/Context.ps1";
|
|
|
|
|
|
|
|
function Install-SoftwarePackage([Context] $context, [string] $location, [string[]] $argumentList = @("/S"), [switch]$local) {
|
|
|
|
[string]$filePath = "";
|
|
|
|
[string]$tempDir = $null;
|
|
|
|
|
|
|
|
if (-not ($local.IsPresent)) {
|
|
|
|
$tempDir = $context.GetTempDirectory();
|
2023-07-15 10:24:04 +00:00
|
|
|
$tempFile = Join-Path $tempDir "download.tmp";
|
2023-07-15 10:18:13 +00:00
|
|
|
|
2023-07-15 10:25:42 +00:00
|
|
|
Write-Information "Downloading setup file from $location";
|
2023-07-15 10:24:04 +00:00
|
|
|
$response = Invoke-WebRequest $location -OutFile $tempFile;
|
2023-07-15 10:21:38 +00:00
|
|
|
$fileName = [System.IO.Path]::GetFileName($response.Headers["Location"]);
|
2023-07-15 10:18:13 +00:00
|
|
|
|
2023-07-15 10:25:42 +00:00
|
|
|
Write-Information "Renaming setup file to $fileName";
|
2023-07-15 10:18:13 +00:00
|
|
|
$filePath = Join-Path $tempDir $fileName;
|
2023-07-15 10:24:04 +00:00
|
|
|
Move-Item $tempFile $filePath;
|
2023-07-15 10:18:13 +00:00
|
|
|
} else {
|
|
|
|
$filePath = $location;
|
|
|
|
}
|
|
|
|
|
2023-07-15 10:25:42 +00:00
|
|
|
$fileName = [System.IO.Path]::GetFileName($filePath);
|
|
|
|
Write-Information "Starting installation of $fileName";
|
2023-07-15 10:18:13 +00:00
|
|
|
Start-Process -Wait -FilePath $filePath -ArgumentList $argumentList;
|
|
|
|
|
|
|
|
if ($tempDir) {
|
|
|
|
Remove-Item -Recurse $tempDir;
|
|
|
|
}
|
|
|
|
}
|