Add functions for installing choco
and winget
packages
This commit is contained in:
parent
d64feb232a
commit
6c193590b1
1 changed files with 52 additions and 0 deletions
|
@ -4,8 +4,60 @@
|
||||||
. "$PSScriptRoot/../Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../Types/InstallerAction.ps1";
|
||||||
|
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
|
. "$PSScriptRoot/SoftwareManagement.ps1";
|
||||||
|
. "$PSScriptRoot/../Types/InstallerAction.ps1";
|
||||||
$userArgument = "name";
|
$userArgument = "name";
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Installs the specified packages using chocolatey.
|
||||||
|
|
||||||
|
.PARAMETER Names
|
||||||
|
The names of the packages to install.
|
||||||
|
#>
|
||||||
|
function Install-ChocoPackage {
|
||||||
|
param(
|
||||||
|
[switch] $Force,
|
||||||
|
[Parameter(ValueFromRemainingArguments = $true)]
|
||||||
|
[string[]] $Names
|
||||||
|
)
|
||||||
|
|
||||||
|
[System.Collections.ArrayList] $Names = $Names;
|
||||||
|
|
||||||
|
if (-not ($Force.IsPresent)) {
|
||||||
|
for ($i = $Names.Count - 1; $i -ge 0; $i--) {
|
||||||
|
if (Test-ChocoPackage $Names[$i]) {
|
||||||
|
$Names.RemoveAt($i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Names.Count -ge 1) {
|
||||||
|
choco install -y $Names;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Installs the specified packages using `winget`.
|
||||||
|
|
||||||
|
.PARAMETER Names
|
||||||
|
The names of the packages to install.
|
||||||
|
#>
|
||||||
|
function Install-WingetPackage {
|
||||||
|
param(
|
||||||
|
[switch] $Force,
|
||||||
|
[Parameter(ValueFromRemainingArguments = $true)]
|
||||||
|
[string[]] $Names
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach ($name in $Names) {
|
||||||
|
if ($Force.IsPresent -and -not (Test-WingetPackage $name)) {
|
||||||
|
winget install --accept-source-agreements --accept-package-agreements -e --id $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function Start-SoftwareInstaller {
|
function Start-SoftwareInstaller {
|
||||||
param(
|
param(
|
||||||
[string] $Name,
|
[string] $Name,
|
||||||
|
|
Loading…
Reference in a new issue