diff --git a/changelogs/fragments/50185-win_updates-report-changes-correctly.yml b/changelogs/fragments/50185-win_updates-report-changes-correctly.yml new file mode 100644 index 00000000000..fe8873933d2 --- /dev/null +++ b/changelogs/fragments/50185-win_updates-report-changes-correctly.yml @@ -0,0 +1,3 @@ +--- +bugfixes: +- win_updates - Correctly report changes on success diff --git a/lib/ansible/modules/windows/win_updates.ps1 b/lib/ansible/modules/windows/win_updates.ps1 index cd4ca990b9c..1626968b8ef 100644 --- a/lib/ansible/modules/windows/win_updates.ps1 +++ b/lib/ansible/modules/windows/win_updates.ps1 @@ -346,7 +346,11 @@ $update_script_block = { $result.reboot_required = (New-Object -ComObject Microsoft.Update.SystemInfo).RebootRequired $result.installed_update_count = $update_success_count $result.failed_update_count = $update_fail_count - + + if ($updates_success_count -gt 0) { + $result.changed = $true + } + if ($update_fail_count -gt 0) { $result.failed = $true $result.msg = "Failed to install one or more updates"