Use Ansible to pull report of Installed, Failed, and Needed Windows Updates from WSUS

Hey all! I am new to Ansible and apologize in advance if this topic has been discussed previously, I was not able to find anything about it. I am currently utilizing Ansible to install Windows updates and reboot the hosts, that’s all working fine. The next issue I want to tackle is reporting on Windows updates from the WSUS servers to see what updates have succeeded, failed, or are still needed. I have found a million ways to fail at this. My current playbook looks like this:

And when I run the playbook with -vvv, I get this output:

We’re looking to deploy this in the near future, so I would really love to get this working quickly. Any help is greatly appreciated!

The error output is saying the flag of “-Update” is ambiguous. I don’t write Powershell so I don’t know what you’re meant to be doing or how you’ll be doing it.

Looking at Get-WsusUpdate (UpdateServices) | Microsoft Learn the switches for Get-WsusUpdate include -UpdateId and -UpdateServer but no -Update. If AI assisted you in creating the Powershell script, it may have hallucinated this part.

Yep, PowerShell tries to select the correct parameter if you do a partial match but in this case there is both -UpdateId or -UpdateServer and -Update can be resolved to either so it fails. Another problem is $ct.FullDomainName, you haven’t defined $ct here, not sure if that’s meant to be $_.FullDomainName or something else.

Just as an FYI I recommend adding $ErrorActionPreference = 'Stop' to the top of your script so that when such errors occur it’ll stop and fail the task.