Windows Update script fails

I have a script which installs windows updates, but the script fails if there are no updates to be installed.

Is there a way that the script can check to see if updates are needed and it not then just do nothing and the script can run successful.

My script is:

You can use information from https://docs.ansible.com/ansible/latest/user_guide/playbooks_error_handling.html like adding entries like:

ignore_errors: true
changed_when: false
failed_when: false