diff --git a/chocolatey/plugins/modules/win_chocolatey.ps1 b/chocolatey/plugins/modules/win_chocolatey.ps1 index 1b06d12..f0a3422 100644 --- a/chocolatey/plugins/modules/win_chocolatey.ps1 +++ b/chocolatey/plugins/modules/win_chocolatey.ps1 @@ -209,7 +209,9 @@ if ($state -in @("downgrade", "latest", "upgrade", "present", "reinstalled")) { $missingPackages = [System.Collections.Generic.List[string]]@() if ($state -eq "present" -and $force) { - $missingPackages.Add($name) + foreach ($package in $name) { + $missingPackages.Add($package) + } } else { foreach ($package in $packageInfo.GetEnumerator()) { diff --git a/chocolatey/tests/integration/targets/win_chocolatey/tasks/tests.yml b/chocolatey/tests/integration/targets/win_chocolatey/tasks/tests.yml index 4e149c9..eacfdab 100644 --- a/chocolatey/tests/integration/targets/win_chocolatey/tasks/tests.yml +++ b/chocolatey/tests/integration/targets/win_chocolatey/tasks/tests.yml @@ -751,3 +751,17 @@ that: - ignore_pinned_upgrade is changed - ignore_pinned_upgrade is not failed + +- name: force install multiple packages + win_chocolatey: + name: + - '{{ test_choco_package1 }}' + - '{{ test_choco_package2 }}' + state: present + register: force_install_multiple + +- name: assert force install multiple packages + assert: + that: + - force_install_multiple is changed + - force_install_multiple is not failed