The Reset Windows Update Agent Script provides a menu of troubleshooting options for the Windows Update service, including fixing corrupt registry values, resetting the Windows Update components, deleting temporary files, and resetting the Winsock settings.
https://gallery.technet.microsoft.com/scriptcenter/Reset-Windows-Update-Agent-d824badc