You could write your script based on the manual steps here.
https://video2.skills-academy.com/en-us/windows/deployment/update/windows-update-resources#reset-windows-update-components-manually
--please don't forget to upvote
and Accept as answer
if the reply is helpful--