diff --git a/scripts/Windows/Scripts/Software.ps1 b/scripts/Windows/Scripts/Software.ps1 index 8cf0d22d..3cdd2776 100644 --- a/scripts/Windows/Scripts/Software.ps1 +++ b/scripts/Windows/Scripts/Software.ps1 @@ -4,8 +4,60 @@ . "$PSScriptRoot/../Types/InstallerAction.ps1"; $null = New-Module { + . "$PSScriptRoot/SoftwareManagement.ps1"; + . "$PSScriptRoot/../Types/InstallerAction.ps1"; $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 { param( [string] $Name,