2024-06-04 20:27:27 -07:00
|
|
|
function Install-WinUtilProgramChoco {
|
2026-05-12 11:06:13 -07:00
|
|
|
param (
|
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
|
[ValidateSet("Install", "Uninstall")]
|
|
|
|
|
[string]$Action,
|
2024-06-29 01:15:39 +03:00
|
|
|
|
2026-05-12 11:06:13 -07:00
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
|
[string[]]$Programs
|
2024-06-04 20:27:27 -07:00
|
|
|
)
|
2024-06-29 01:15:39 +03:00
|
|
|
|
2026-05-12 11:06:13 -07:00
|
|
|
if ($Action -eq 'Install') {
|
2026-07-01 21:49:15 -05:00
|
|
|
$arguments = "install $Programs -y"
|
2026-05-12 11:06:13 -07:00
|
|
|
} else {
|
2026-07-01 21:49:15 -05:00
|
|
|
$arguments = "uninstall $Programs -y"
|
2024-09-10 20:02:22 +02:00
|
|
|
}
|
2026-07-01 21:49:15 -05:00
|
|
|
|
|
|
|
|
Write-WinUtilLog -Component "Package" -Message "$Action choco package(s): $($Programs -join ', ')"
|
|
|
|
|
$process = Start-Process -FilePath choco -ArgumentList $arguments -NoNewWindow -Wait -PassThru
|
|
|
|
|
Write-WinUtilLog -Component "Package" -Message "$Action choco package(s) completed: $($Programs -join ', ') (exit code: $($process.ExitCode))"
|
2024-06-04 20:27:27 -07:00
|
|
|
}
|