Add missing function

This commit is contained in:
Manuel Thalmann 2024-08-08 04:20:11 +02:00
parent 223249e1c4
commit f347f2b3ec

View file

@ -73,6 +73,50 @@ $null = New-Module {
}
}
<#
.SYNOPSIS
Installs a setup package from the specified source.
.PARAMETER Source
The location of the setup package.
.PARAMETER ArgumentList
The arguments to pass to the setup package.
.PARAMETER Local
A value indicating whether the setup package is stored locally.
#>
function Install-SetupPackage {
param(
[string] $Source,
[string[]] $ArgumentList = @("/S"),
[switch] $Local
)
[string] $dir = $null;
[string] $filePath = $null;
if (-not ($Local.IsPresent)) {
$dir = New-TemporaryDirectory;
Write-Host "Determining the file name of ``$Source``";
$fileName = ([uri]$Source).Segments[-1];
Write-Host "Found name ``$fileName``";
$filePath = Join-Path $dir $fileName;
Write-Host "Downloading setup file from ``$Source``";
Invoke-WebRequest $Source -OutFile $filePath;
} else {
$filePath = $Source;
}
Write-Host "Starting installation of ``$(Split-Path -Leaf $filePath)``";
Start-Process -Wait -WorkingDirectory (Split-Path -Parent $filePath) -FilePath $filePath -ArgumentList $ArgumentList;
if ($dir) {
Remove-Item -Recurse $dir;
}
}
<#
.SYNOPSIS
Installs a package downloaded from ASUS.