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)) {
|
2023-07-16 00:01:31 +00:00
|
|
|
$tempDir = $context.GetTempDirectory();
|
2023-07-15 23:46:57 +00:00
|
|
|
Write-Information "Determining the file name of $location";
|
2023-07-15 23:56:51 +00:00
|
|
|
$fileName = ([uri]$location).Segments[-1];
|
2023-07-15 23:46:57 +00:00
|
|
|
Write-Information "$fileName";
|
|
|
|
$filePath = Join-Path $tempDir $fileName;
|
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 23:46:57 +00:00
|
|
|
Invoke-WebRequest $location -OutFile $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;
|
|
|
|
}
|
|
|
|
}
|