Add missing function
This commit is contained in:
parent
b92173fa25
commit
e29e36acf7
1 changed files with 44 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue